Go to Post In theory, this should work... Oops. - Eldarion [more]
Home
Go Back   Chief Delphi > Other > Math and Science
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 14-07-2016, 10:28
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Math Quiz 9


What's the average length of all the line segments which can be drawn inside a 1 inch square?

(accurate to 5 decimal digits)

(show your work)



Attached Thumbnails
Click image for larger version

Name:	square.png
Views:	184
Size:	1.8 KB
ID:	20908  
Reply With Quote
  #2   Spotlight this post!  
Unread 14-07-2016, 10:51
Jon Stratis's Avatar
Jon Stratis Jon Stratis is offline
Electrical/Programming Mentor
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,719
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: Math Quiz 9

point of clarification: I assume you mean the average of all possible line segments, which allows for intersecting and overlapping lines, if drawn within a single square. For example, you could have an X formed by two lines stretching from opposite corners, or you could have two lines that lay on top of each other, one going from corner to opposite corner and the other from the center to the same corner.
__________________
2007 - Present: Mentor, 2177 The Robettes
LRI: North Star 2012-2016; Lake Superior 2013-2014; MN State Tournament 2013-2014, 2016; Galileo 2016; Iowa 2017
2015: North Star Regional Volunteer of the Year
2016: Lake Superior WFFA
Reply With Quote
  #3   Spotlight this post!  
Unread 14-07-2016, 13:48
smitikshah's Avatar
smitikshah smitikshah is offline
Drive Coach
AKA: Smiti
FRC #2869 (Regal Eagles)
Team Role: Coach
 
Join Date: Dec 2015
Rookie Year: 2015
Location: New York
Posts: 145
smitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond repute
Re: Math Quiz 9

by "inside" are they allowed to touch the edge of the square?
__________________
Reply With Quote
  #4   Spotlight this post!  
Unread 14-07-2016, 14:07
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by smitikshah View Post
by "inside" are they allowed to touch the edge of the square?
Does it matter?


Reply With Quote
  #5   Spotlight this post!  
Unread 14-07-2016, 14:34
Jon Stratis's Avatar
Jon Stratis Jon Stratis is offline
Electrical/Programming Mentor
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,719
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: Math Quiz 9

My second attempt over lunch came up with 0.55272, but I'm pretty sure that's not right (It's too high). I know what i'm missing from my equations (logically, even if i haven't figured out how to express it mathematically just yet) though.

I just wish I remembered more of my calculus than I do!
__________________
2007 - Present: Mentor, 2177 The Robettes
LRI: North Star 2012-2016; Lake Superior 2013-2014; MN State Tournament 2013-2014, 2016; Galileo 2016; Iowa 2017
2015: North Star Regional Volunteer of the Year
2016: Lake Superior WFFA
Reply With Quote
  #6   Spotlight this post!  
Unread 14-07-2016, 15:12
Jon Stratis's Avatar
Jon Stratis Jon Stratis is offline
Electrical/Programming Mentor
FRC #2177 (The Robettes)
Team Role: Mentor
 
Join Date: Feb 2007
Rookie Year: 2006
Location: Minnesota
Posts: 3,719
Jon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond reputeJon Stratis has a reputation beyond repute
Re: Math Quiz 9

I finally came up with 0.28967 as my final answer. Work below, colored white so people can ignore it until they've done their own work on the problem Note: I don't remember my calculus very well anymore, so I had to use wolfram alpha to get me (hopefully) close enough!

To solve this (assuming it's correct), I needed a couple of components and assumptions/assertions.

Lets start with a simple case - the average length of line segments contained within a N length line. A good description of this can be found here: http://math.stackexchange.com/questi...ints-on-a-line

What that boils down to, is that if I draw a line such that it intersects two edges of the square, taking the length of that line divided by 3 gives me the average length of every line segment that sits on that line. This little trick lets us GREATLY simplify the calculations, as we can use it to assume we're only looking at lines that intersect two walls of the square, and effectively ignore snort lines that don't intersect the lines of the square.

So, with that in hand, we can now figure out the length of every possible line that intersects two lines of the square. This can be broken down into two categories: lines that intersect adjacent edges of the square, and lines that intersect non-adjacent edges. Due to the symmetry of a square, we know that the first group can be simplified into 4 repetitions (top/right, right/bottom, bottom/left, left/top) and the second into 2 repetitions (top/bottom, left/right). This will come in handy later.

So, lets look at the case where you have adjacent sides. You really have two variables here, X and Y, each being an independent number between 0 and 1 representing their location on one of the sides, and the line that stretches between them. The length of that line, as defined by the Pythagorean Theorem is sqrt(x^2+y^2)... but remember we want that length/3 to get the average length of line segments along it. And remember that we have an infinite number of points between 0 and 1 for both x and y... calculus! So, written in a form wolfram alpha will recognize, integrating over x and y gives us:

integrate integrate (sqrt(x^2+y^2)/3) dx dy from 0 to 1 from 0 to 1

or 0.255065.

We can do the same for the case of non adjacent sides. Here the equation is a little trickier, but ultimately the line length is sqrt((x-y)^2+1). Dividing by 3 and integrating gives us:

integrate integrate (sqrt((x-y)^2+1)/3) dx dy from 0 to 1 from 0 to 1

or 0.358879.

Keep in mind that the average of an integral is that integral times 1/(b-a) - in this case, b-a is 1, so we don't need to do anything else.

So, lets get these two numbers together. Remember, we have 4 sets of the adjacent sides, and 2 sets of the non-adjacent sides. And since those sides all integrated over the same values, we should just be able to average the sets, right? So, averaging those in proportion gives us:

(4*0.255065 + 2*0.358879)/6

or 0.28967.
__________________
2007 - Present: Mentor, 2177 The Robettes
LRI: North Star 2012-2016; Lake Superior 2013-2014; MN State Tournament 2013-2014, 2016; Galileo 2016; Iowa 2017
2015: North Star Regional Volunteer of the Year
2016: Lake Superior WFFA
Reply With Quote
  #7   Spotlight this post!  
Unread 14-07-2016, 17:10
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by Jon Stratis View Post
I finally came up with 0.28967 as my final answer.
Do a sanity check with a simple Monte Carlo simulation.


Reply With Quote
  #8   Spotlight this post!  
Unread 20-07-2016, 15:44
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Math Quiz 9


Wrapping up some loose ends...

Quote:
Originally Posted by smitikshah View Post
by "inside" are they allowed to touch the edge of the square?
Quote:
Originally Posted by Ether View Post
Does it matter?
Why or why not? Explain.

Reply With Quote
  #9   Spotlight this post!  
Unread 20-07-2016, 16:41
Hitchhiker 42's Avatar
Hitchhiker 42 Hitchhiker 42 is offline
Roboter
AKA: Mark Lavrentyev
FRC #4557 (FullMetal Falcons)
Team Role: Programmer
 
Join Date: Oct 2015
Rookie Year: 2015
Location: Cromwell, CT
Posts: 459
Hitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to beholdHitchhiker 42 is a splendid one to behold
Re: Math Quiz 9

Quote:
Originally Posted by Ether View Post

Wrapping up some loose ends...



Why or why not? Explain.

If I could,

The reason I don't think it matters is that let's say you were to take one end point of any line very very very close to the edge. If you keep pushing it infinetly closer, it's essentially on the edge already (limits woo), so it doesn't matter.
__________________



2016 - NE District Championship Entrepreneurship Award
2016 - Hartford District Industrial Design Award
2016 - Waterbury District Engineering Inspiration Award
Reply With Quote
  #10   Spotlight this post!  
Unread 21-07-2016, 18:51
smitikshah's Avatar
smitikshah smitikshah is offline
Drive Coach
AKA: Smiti
FRC #2869 (Regal Eagles)
Team Role: Coach
 
Join Date: Dec 2015
Rookie Year: 2015
Location: New York
Posts: 145
smitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by Hitchhiker 42 View Post
If I could,

The reason I don't think it matters is that let's say you were to take one end point of any line very very very close to the edge. If you keep pushing it infinetly closer, it's essentially on the edge already (limits woo), so it doesn't matter.
Ah okay that makes sense. Thanks!
__________________
Reply With Quote
  #11   Spotlight this post!  
Unread 21-07-2016, 00:34
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,531
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by Ether View Post

Wrapping up some loose ends...



Why or why not? Explain.

Enough hours have passed:

Allowing the borders of the square does NOT matter. The likelihood of one of the endpoints falling in any given area within the permissible bounds is proportional to the area. The lines at the edge of the square have length but zero area, so even if they're allowed, the selected point will "never" be on the edge. A bit more formally, the chances of a point on an edge being chosen is infinitesimally small and (excepting something massively discontinuous like a delta function) does not affect the integration over the area.
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #12   Spotlight this post!  
Unread 21-07-2016, 18:52
smitikshah's Avatar
smitikshah smitikshah is offline
Drive Coach
AKA: Smiti
FRC #2869 (Regal Eagles)
Team Role: Coach
 
Join Date: Dec 2015
Rookie Year: 2015
Location: New York
Posts: 145
smitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond reputesmitikshah has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by GeeTwo View Post
Enough hours have passed:

Allowing the borders of the square does NOT matter. The likelihood of one of the endpoints falling in any given area within the permissible bounds is proportional to the area. The lines at the edge of the square have length but zero area, so even if they're allowed, the selected point will "never" be on the edge. A bit more formally, the chances of a point on an edge being chosen is infinitesimally small and (excepting something massively discontinuous like a delta function) does not affect the integration over the area.
Thank you!
__________________
Reply With Quote
  #13   Spotlight this post!  
Unread 21-07-2016, 09:18
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Math Quiz 9



What's the average length of all the line segments whose endpoints both lie on the unit square's perimeter?


Reply With Quote
  #14   Spotlight this post!  
Unread 21-07-2016, 11:36
z_beeblebrox's Avatar
z_beeblebrox z_beeblebrox is online now
Custom User Title
AKA: Cal
FRC #4183 (Bit Buckets)
Team Role: Alumni
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Cambridge MA
Posts: 811
z_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond reputez_beeblebrox has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by Ether View Post


What's the average length of all the line segments whose endpoints both lie on the unit square's perimeter?


Modified above Monte Carlo code to solve this:

Code:
import numpy as np

iterations = 100000

avg = 0

for i in range(1000):
    print(i)
    for j in range(iterations):
        perimeter = 4*np.random.rand(2)

        if perimeter[0] < 1:
            y1 = 0
            x1 = perimeter[0]
        elif perimeter [0] < 2:
            y1 = perimeter[0] - 1
            x1 = 1
        elif perimeter[0] < 3:
            y1 = 1
            x1 = 3 - perimeter[0]
        else:
            y1 = 4 - perimeter[0]
            x1 = 0

        if perimeter[1] < 1:
            y2 = 0
            x2 = perimeter[1]
        elif perimeter[1] < 2:
            y2 = perimeter[1] - 1
            x2 = 1
        elif perimeter[1] < 3:
            y2 = 1
            x2 = 3 - perimeter[1]
        else:
            y2 = 4 - perimeter[1]
            x2 = 0

        length = np.sqrt((x1-x2)**2+(y1-y2)**2)
        avg = (avg*j + length)/(j+1)
    with open("9.1.txt", "a") as f:
        f.write(str(avg)+'\n')
2.1e7 iterations yields 0.73511, standard deviation 0.00095 (between blocks averaging 1e6 iterations). More iterations will give a more accurate answer.
__________________
2012 Utah Regional Rookie All-Star
2013 Phoenix Regional Judge's Award for "design process and prototyping"
2014 Hub City Regional Quality Award, Arizona Regional Excellence in Engineering Award
2015 Arizona East Regional Creativity Award, Winner
2016 Arizona North Regional Finalist, Arizona West Excellence in Engineering Award, Finalist

Last edited by z_beeblebrox : 21-07-2016 at 11:44.
Reply With Quote
  #15   Spotlight this post!  
Unread 22-07-2016, 11:30
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 7,995
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Math Quiz 9

Quote:
Originally Posted by z_beeblebrox View Post
2.1e7 iterations yields 0.73511
Close enough

Two billion samples yields a value about 0.003% less than that. Plotting the average vs the number of samples gives a rough view of when you've reached the point of diminishing returns.

Note that this problem can be easily solved using all three methods discussed in this thread:

Monte Carlo simulation

Numerical Integration

Symbolic Integration


Quote:
Originally Posted by z_beeblebrox View Post
standard deviation 0.00095
Standard deviation is not so meaningful when the distribution looks this this.


Attached Thumbnails
Click image for larger version

Name:	Monte Carlo simulation (Delphi).png
Views:	11
Size:	5.2 KB
ID:	20927  Click image for larger version

Name:	numerical integration (Octave).png
Views:	10
Size:	9.8 KB
ID:	20928  Click image for larger version

Name:	symbolic integration (Maxima).png
Views:	13
Size:	22.0 KB
ID:	20929  Click image for larger version

Name:	average vs samples.png
Views:	11
Size:	9.6 KB
ID:	20930  Click image for larger version

Name:	histogram.png
Views:	33
Size:	8.8 KB
ID:	20931  

Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:45.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi