Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

Pages: **1**

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 98,926

**Hi;**

**This question appeared on another site:**

**3 sectors are drawn in the unit circle.One sector is 18° another is 36° and the last is 54°. What is the probability that all 3 sectors overlap with each other?**

**See figure 1 for a pictorial representation of the problem.**

**The exact probability is 11 / 400 but let us see what geogebra and mathematica can manage if we do not know that.**

**1)Draw 2 circles 1 at the origin with a radius of 1 and another at (1.5,0) with a readius of .15 using the Circle with Center and Radius tool.**

**2) For the smaller circle color it red with an opacity of 100% and hide the center point. Hide the xy axes.**

**3) Create a slider that uses integers from 1 to 2000 and put it in the right hand corner.**

**4) Create 3 random numbers:**

**r1 = n / n RandomUniform[0, 359]r2 = n / n RandomUniform[0, 359]r3 = n / n RandomUniform[0, 359]**

**the purpose of the weird notation will be explained later.**

**5) Create points(cos(r1°), sin(r1°)) and (cos((r1 + 18)°), sin((r1 + 18)°)). Point C and D will appear on the circle with an 18 degree angle between them.**

**6) Draw polygon ACD, color it red with an opacity of 50%. Find the midpoint of CD with the midpoint tool. Hide C and D you should only have the red sector and the point E. Hit the F9 key a few times to see the random 18 degree sector being drawn.**

**7) Create points(cos(r2°), sin(r2°)) and (cos((r2 + 36)°), sin((r2 + 36)°)). Point F and G will appear on the circle with an 36 degree angle between them.**

**8) Draw polygon AFG, color it green with an opacity of 50%. Find the midpoint of FG with the midpoint tool. Hide F and G you should only have the green and red sector and the point E and H.**

**9) Create points(cos(r3°), sin(r3°)) and (cos((r3 + 54)°), sin((r3 + 54)°)). Point F and G will appear on the circle with an 54 degree angle between them.**

**10) Draw polygon AJI, color it blue with an opacity of 50%. Find the midpoint of JI with the midpoint tool. Hide J and I you should only have the green, red and blue sector and the point E , H and K.**

**If you press F9 now you will see 3 random sectors created, we just now need to determine when there is a triple intersection and to count them.**

**11) Create a counter variable by entering counter = 0.**

**12) Create an input box using the insert input box tool and give it a Caption of reset and link it with counter. Give it an input length of 5 characters. Whatever you enter into its box will be assigned to the variable called counter. We will use it to zero it.**

**13) Get the object properties of the small red circle and in the advanced tab type this without quotes into the Condition to Show Object box,"(Distance[E, H] ≤ 0.45399) ∧ (Distance[K, H] ≤ 0.69466) ∧ (Distance[E, K] ≤ 0.58779)."**

**14) In the Scripting tab enter "If[(Distance[E, H] ≤ 0.45399) ∧ (Distance[K, H] ≤ 0.69466) ∧ (Distance[E, K] ≤ 0.58779),SetValue[counter,counter+1]]" in the On Update box.**

**15) Create another counter by just entering counter / n in the input bar, rename it to percentage. You may notice that in addition to F9 generating 3 sectors, the slider n also does and that when there is a triple intersection the red circle comes on.**

**Okay we are ready, move the slider all the way to the left. Enter in the Reset box 0. Set the slider in properties to increasing once. Highlight the slider and hold down the right arrow key to run the simulation. Slow down when you get close to 2000 so you can stop right on it. I got 50, for a percentage of .025 which is pretty close for only a run of 2000. What did you get?**

**With Mathematica we can do a little bit better. With a run of 200000 I got .0272 which is quite good.**

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 15,954

Where can I see the analytic answer, if one exists?

Also, I must try this one. Looks cool.

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 98,926

I can post it, if you want it.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**anonimnystefy****Real Member**- From: Harlan's World
- Registered: 2011-05-23
- Posts: 15,954

Sure. I just thought it was already somewhere on the forum.

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

The knowledge of some things as a function of age is a delta function.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 98,926

Hi;

Daniel C wrote:

The probability two sectors with central angles α and β intersect is (α+β) / (2π).

This can easily be proven with a diagram. The second sector can be right to the left or right of the first, or anywhere in between. This results in an angle of α+β.

Now, to the problem. Fix the sector with central angle π/10, and call it A. Consider the sector with central angle 2π/10, and call it B. The third sector is C. The probability B intersects A is 3/20, by the fact above.

Now, let f be the function that models the intersection of A and B for each position. Since area is linearly dependent on angle, f first rises, stays constant, and then falls (draw it yourself; draw a circle, a sector, and see where the second sector can intersect the first). The graph looks like a hill.

Either way, the point is that the expected value for the area of the intersection is π/15. Now, by our fact above, the probability that C intersects our current intersection is 11/60. Once again, this is valid because area is linearly dependent on angle.

Our probability is, multiplying our two probabilities:

3/20⋅11/60=11/400

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**ElainaVW****Member**- Registered: 2013-04-29
- Posts: 470

Hello M:

Thanks for all the work. Why did you choose polar coordinates and not vectors or the Sector command for the sectors? Can you post the Mathematica code when you get a chance?

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 98,926

Hi;

Polar was a last resort, after more than a week of fumbling with those vectors, I finally gave up. Anyways, they have the same problem the sector command does. It was difficult to tell when there was a triple intersection. In the end the polygon - polar idea with the distance between the midpoints that finally worked. The M code is on the way.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**ElainaVW****Member**- Registered: 2013-04-29
- Posts: 470

Working with it a tiny bit you do not need the midpoint idea at all. There is an IntersectRegion command that might work better.:)

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 98,926

Hi;

I discovered that too after I had posted the program. It does appear to be a substantial improvement.

Here is the code you requested:

```
dist[{x1_,y1_},{x2_,y2_}]:=\[Sqrt]((x2-x1)^2+(y2-y1)^2);
midpoint[{{x1_,y1_},{x2_,y2_}}]:={(x1+x2)/2,(y1+y2)/2};
sectormid[arcangle_] := Module[{a = RandomInteger[{0, 360}]},
arc1 = {{Cos[Degree*a], Sin[Degree*a]}, {Cos[Degree*(a + arcangle)],
Sin[Degree*(a + arcangle)]}} // N;
midpoint[arc1]];
ans=Table[{sectormid[18],sectormid[36],sectormid[54]},{100000}];
s1=Select[ans,dist[First[#],#[[2]]]<=0.45399&];
s2=Select[s1,dist[First[#],#[[3]]]<=0.58779&];
s3=Select[s2,dist[#[[2]],#[[3]]]<=0.69466&];Length[s3]/100000.
```

As you can see there is much chance for improvement. It will run faster on your machines than mine too.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**ElainaVW****Member**- Registered: 2013-04-29
- Posts: 470

The dist function can be improved. We can leave out the radical for faster execution.

It might be compilable. I see why you stuck with the midpoint idea for both.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 98,926

Hi;

Yes, it was the only way that could work in both programs. M does not have an IntersectRegion command.

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**ElainaVW****Member**- Registered: 2013-04-29
- Posts: 470

This could be solved by using the built in functions that Mathematica supplies.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 98,926

Hi;

I have been playing with that all night. So far, I have not done it. Perhaps you will?

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

Hi bobbym,

This can also be done without calculating the midpoints. We can consider the sample angle itself as the angle of the midpoint, and then calculate the distance.

The threshold of the distances are sqrt(2*(1-cos 27)), sqrt(2*(1-cos 36)) and sqrt(2*(1-cos 45))

J simulation:

```
load 'trig'
samp =: 1000000
a1=:(?samp$360)*1p1%180 NB. The angles
a2=:(?samp$360)*1p1%180
a3=:(?samp$360)*1p1%180
x1=:cos a1 NB. The points
y1=:sin a1
x2=:cos a2
y2=:sin a2
x3=:cos a3
y3=:sin a3
d1=:(((x1-x2)^2)+(y1-y2)^2)^%2 NB. The distances
d2=:(((x1-x3)^2)+(y1-y3)^2)^%2
d3=:(((x3-x2)^2)+(y3-y2)^2)^%2
l1=:d1<0.618034 NB. Conditions to be met
l2=:d2<0.76536686
l3=:d3<0.46689
(+/%#)(l1*.l2)*.l3
```

≈0.027433

Time taken for execution is about 0.758 seconds.

"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 98,926

Hi gAr;

She came to the same conclusion. Very good work!

**In mathematics, you don't understand things. You just get used to them.****If it ain't broke, fix it until it is.** **Thinking is cheating.**

Offline

**gAr****Member**- Registered: 2011-01-09
- Posts: 3,479

Hi bobbym,

Thanks for the idea

"Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense" - Buddha?

"Data! Data! Data!" he cried impatiently. "I can't make bricks without clay."

Offline

Pages: **1**