Randomly plotting the angle

A B C D ABCD is a square; and P P is a random point inside it. Find the expected angle of θ \theta in degrees.

Bonus: Find the probability density function of θ \theta .


Find the median angle instead .
Fidn the mode angle instead .


The answer is 90.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Chris Lewis
Sep 7, 2020

The expected values of A P B \angle APB , B P C \angle BPC , C P D \angle CPD and D P A \angle DPA will (by symmetry) all be the same; call this value θ \overline{\theta} .

So the expected value of A P B + B P C + C P D + D P A \angle APB+\angle BPC+\angle CPD+\angle DPA will be 4 θ 4\overline{\theta} .

But, for any point P P in the interior of the square, A P B + B P C + C P D + D P A = 36 0 \angle APB+\angle BPC+\angle CPD+\angle DPA=360^{\circ} .

Hence θ = 9 0 \overline{\theta}=\boxed{90^\circ} .

OMG, this is simpler than I thought.

Pi Han Goh - 9 months, 1 week ago

Log in to reply

Same here - I coded it first, got 89. 9 89.9^\circ , then realised why! The proof felt like such a cheat after getting my laptop to do the hard work.

Chris Lewis - 9 months, 1 week ago

This seems to get tricky if A B C D ABCD is a rectangle...

Chris Lewis - 9 months, 1 week ago

Log in to reply

Lemme work on a rectangular version and see what I can come up with.

Pi Han Goh - 9 months, 1 week ago

Log in to reply

I've managed to get a closed formula that matches computed values, but it's not pretty. I can share it here, or shall I post it as a solution to your next problem? ;-)

Chris Lewis - 9 months, 1 week ago

Log in to reply

@Chris Lewis Go ahead and post it as your own problem then. Here is the raw text:

1
2
3
4
5
6
7
![](https://ds055uzetaobb.cloudfront.net/uploads/1GLTxIDwvN-probability-of-acute-angle.png|width=500){: .center}

\\\( ABCD \\\) is a square; and \\\( P \\\) is a random point inside it.  Find the expected angle of \\\(\\theta\\\) in degrees.

\\\[\\\]**Bonus:** Find the probability density function of \\\(\\theta\\\).

\\\[\\\][Inspiration](https://brilliant.org/problems/how-likely-is-it-to-get-an-acute-angle/). 

Pi Han Goh - 9 months, 1 week ago

Log in to reply

@Pi Han Goh Thanks - will do, I'm just looking for a rectangle where the exact answer isn't too horrific (spoiler alert: it's usually horrific)

Chris Lewis - 9 months, 1 week ago

Log in to reply

@Chris Lewis Yeah, I'm working on it as we speak. I'm also simultaneously working on the solution that James Arruda claimed , that the optimal expected value is 3.60 something something something....

Pi Han Goh - 9 months, 1 week ago

Log in to reply

@Pi Han Goh OK...posted...but it's not pretty! The approach you were looking at in your solution here (using cosine rule) is different to mine, so maybe (hopefully) there's a neat way to solve for rectangles too. Please upload a solution if you find one!

Chris Lewis - 9 months, 1 week ago

Log in to reply

@Chris Lewis I randomly guessed some integers and got it right. I still can't solve it though and I'm weeping right now.

Pi Han Goh - 9 months, 1 week ago

Log in to reply

@Pi Han Goh Uh-oh...sorry, not the intention!!! Still, glad you got it right. I'm betting I've missed something way easier than my approach there.

Chris Lewis - 9 months, 1 week ago

@Chris Lewis It definitely depends on the dimensions. And I guess that the ratio will definitely be involved there as well

Mahdi Raza - 9 months, 1 week ago

Log in to reply

@Mahdi Raza it actually depends on 1 dimension only. Without the loss of generality, we can assume the dimensions of the rectangle to be 1 × M 1 \times M .

Pi Han Goh - 9 months, 1 week ago

Log in to reply

@Pi Han Goh Ok, so you are saying that if we consider dimensions to be ( a , b ) (a,b) it is equivalent to say that the dimensions are ( 1 , b a ) (1, \dfrac{b}{a}) where b a = M \dfrac{b}{a} = M . Makes sense. Because angles do not depend on the size.

Mahdi Raza - 9 months, 1 week ago

Log in to reply

@Mahdi Raza Yuppers.

By the way, super big fan of your animations in the Daily Challenges!

Pi Han Goh - 9 months, 1 week ago

Log in to reply

@Pi Han Goh Great! What should be the next step... any hints if you've figured it out?

Thank you so much though!! 😊 😊

Mahdi Raza - 9 months, 1 week ago

Log in to reply

@Mahdi Raza Haha, I'm as lost as you are. I'm just fumbling around by doodling random alien symbols, praying to God for a sign.

Pi Han Goh - 9 months, 1 week ago

Log in to reply

@Pi Han Goh lol, I should start praying too then ;)

Mahdi Raza - 9 months, 1 week ago

Oh Wow wow! really simple once you know it...

Mahdi Raza - 9 months, 1 week ago

That is my first thought of trying to solve the "Inspiration" question, but then figure it out the 4 angles will have some instance to be acute at the same time. That is the right time to use this argument!

Pop Wong - 9 months, 1 week ago

Instead of finding the mean of this angle, what about its median? Monte-Carlo suggests it's around 1.384 .

Pi Han Goh - 8 months ago

Log in to reply

Could be a coincidence, but that's very close to 8 0 80^\circ . You mention finding the probability distribution in the question - did you manage to get an expression for that?

Chris Lewis - 8 months ago

Log in to reply

Well, the other solution poster pointed out that:

θ = π 2 tan 1 ( y x ) , \theta = \pi - 2\tan^{-1} (\tfrac yx) , where x , y x,y are independent and identical continuous uniform distribution, U [ 0 , 1 ] U \sim [0,1] . That's all I can gather.

Pi Han Goh - 8 months ago

Sure enough, five weeks later...

If the coordinates of P P are ( x , y ) (x,y) , then θ = tan 1 y x + tan 1 1 y x \theta=\tan^{-1} \frac{y}{x}+\tan^{-1} \frac{1-y}{x}

Taking the tangent of both sides, tan θ = y x + 1 y x 1 y x 1 y x tan θ = x x 2 y + y 2 ( x 2 y + y 2 ) tan θ = x \begin{aligned} \tan \theta &=\frac{ \frac{y}{x}+\frac{1-y}{x}}{1-\frac{y}{x} \cdot \frac{1-y}{x}} \\ \tan \theta &=\frac{x}{x^2-y+y^2} \\ \left(x^2-y+y^2 \right) \tan \theta &=x \end{aligned}

which we recognise as the equation of a circle. In fact, it's the equation of a circle with centre ( 1 2 cot θ , 1 2 ) (\frac12 \cot \theta,\frac12) and radius 1 2 csc θ \frac12 \csc \theta . As you might intuitively expect, this circle passes through ( 0 , 0 ) (0,0) and ( 0 , 1 ) (0,1) as well.

If we fix θ \theta , the intersection of this circle with the original square is the locus of points P P such that A P B = θ \angle APB=\theta .

To find the median value of θ \theta , then, we just need to find the value of θ \theta so this locus splits the square into two regions of equal area.

The region enclosed by the locus and the square is made up of a rectangular portion and a circular segment. Its area is given by cot θ + 2 θ sin 2 θ 8 sin 2 θ \cot \theta+\frac{2\theta-\sin 2\theta}{8\sin^2 \theta}

We want this equal to 1 2 \frac12 . Solving numerically, we find θ = 1.3841 \theta=1.3841\ldots for the median.

Chris Lewis - 8 months ago

Log in to reply

Once you're done, post it as a problem of your own, and let me cry because I can't solve it.

Also, don't forget to work on the mode as well, which is about 1.253131 rad 71. 8 1.253131 \text { rad} \approx 71.8^\circ .

Pi Han Goh - 8 months ago

Log in to reply

Well, I daren't post it, as we seem to have a discrepancy - any ideas?? I'll have a look at the mode, but meantime I found it useful to look at this on Desmos - that's when I realised it was just a bit of a circle all along. If you paste this...

\arctan\left(\frac{y}{x}\right)+\arctan\left(\frac{1-y}{x}\right)=c\left{0<y<1\right}\left{0<x<1\right}

...into Desmos you should get a slider that lets you play with the graph.

Chris Lewis - 8 months ago

Log in to reply

@Chris Lewis Well, I'm pretty sure my results are correct (to the first few decimal places). I've posted my Monte Carlo simulation under Arghyadeep's solution.

Pi Han Goh - 8 months ago

Log in to reply

@Pi Han Goh Yep, you were right! (This, by the way, is why I almost always Monte Carlo these things first; I - correctly - have zero faith in my ability to crunch through these equations mistake-free!!)

Chris Lewis - 8 months ago

Log in to reply

@Chris Lewis By the way, how did you work out the mode?

Chris Lewis - 8 months ago

Log in to reply

@Chris Lewis No idea. I'm still thinking about it. Maybe differentiate the integrand and find the maximum point??

Pi Han Goh - 8 months ago

Log in to reply

@Pi Han Goh You mentioned you had found it was 1.253 1.253\ldots using Monte Carlo, but I seem to be finding it's a bit less than one. (I've tried both MC and just scanning the space with a fine grid; I counted the number of times the angle was in each interval ( 0.75 , 0.8 ) (0.75,0.8) , ( 0.8 , 0.85 ) (0.8,0.85) etc; the modal interval seems to be coming out as somewhere around 0.95 0.95 for me).

Chris Lewis - 8 months ago

Log in to reply

@Chris Lewis You're right. Sorry my bad. I've reduced the amount of trials to test something and the value fluctuates badly.

Pi Han Goh - 8 months ago

Log in to reply

@Pi Han Goh Ah, OK, thanks. Well, I've found a value around that one via a couple of different numerical methods; my analytical approach is not working at all yet.

Chris Lewis - 8 months ago

Summoning @Mark Hennings because he seems to be unbelievably great at this area.

To Mark:

In this problem, we have found the expected value of A P B \angle APB to be exactly 9 0 90^\circ . Arghyadeep's solution shows a clean calculus solution. I tried working on a closed-form for the variance of this same angle, and it all boils down to 0 1 0 1 ( tan 1 ( y x ) ) 2 d y d x \int \limits_0^1 \int \limits_0^1 (\tan^{-1} (\tfrac yx) )^2 \, dy \, dx , which even Mathematica can't seem to tackle.

Next, I thought about finding the median and mode. And I've worked them out with a Monte-Carlo simulation (under Arghyadeep's solution), but nothing seems to come to fruition.

Pi Han Goh - 8 months ago

Log in to reply

Using the double variable substitution u = x y u =xy , v = y / x v = y/x , we have the Jacobian ( u , v ) ( x , y ) = 2 y x = 2 v \frac{\partial(u,v)}{\partial(x,y)} \; = \; \frac{2y}{x} \; = \; 2v and hence the integral J = 0 1 0 1 ( tan 1 y x ) 2 d x d y = 1 2 0 d v 0 m i n ( v , v 1 ) d u v 1 ( tan 1 v ) 2 = 1 2 0 1 ( tan 1 v ) 2 d v + 1 2 1 v 2 ( tan 1 v ) 2 d v = 1 2 0 1 ( ( tan 1 v ) 2 + ( 1 2 π tan 1 v ) 2 ) d v = 0 1 ( tan 1 v ) 2 d v 1 2 π 0 1 tan 1 v d v + 1 8 π 2 \begin{aligned} J & = \; \int_0^1 \int_0^1 \left(\tan^{-1}\tfrac{y}{x}\right)^2\,dx\,dy \; = \; \tfrac12\int_0^\infty\,dv \int_0^{\mathrm{min}(v,v^{-1})}\,du \,v^{-1}\big(\tan^{-1}v\big)^2 \\ & = \; \tfrac12\int_0^1 \big(\tan^{-1}v\big)^2\,dv + \tfrac12\int_1^\infty v^{-2}\big(\tan^{-1}v\big)^2\,dv \\ & = \; \tfrac12\int_0^1 \left(\big(\tan^{-1}v\big)^2 + \big(\tfrac12\pi - \tan^{-1}v\big)^2\right)\,dv \\ & =\; \int_0^1 \big(\tan^{-1}v\big)^2\,dv - \tfrac12\pi \int_0^1 \tan^{-1}v\,dv + \tfrac18\pi^2 \end{aligned} Integrating by parts, 0 1 tan 1 v d v = [ v tan 1 v ] 0 1 0 1 v 1 + v 2 d v = 1 4 π [ 1 2 ln ( 1 + v 2 ) ] 0 1 = 1 4 π 1 2 ln 2 \int_0^1 \tan^{-1}v\,dv \; = \; \Big[v \tan^{-1}v\Big]_0^1 - \int_0^1 \frac{v}{1+v^2}\,dv \; = \; \tfrac14\pi - \Big[\tfrac12\ln(1+v^2)\Big]_0^1 \; = \; \tfrac14\pi - \tfrac12\ln2 so that J = 0 1 ( tan 1 v ) 2 d v + 1 4 π ln 2 J \; = \; \int_0^1 \big(\tan^{-1}v\big)^2\,dv + \tfrac14\pi \ln2 Integrating by parts twice more: J = [ v ( tan 1 v ) 2 ] 0 1 0 1 2 v tan 1 v 1 + v 2 d v + 1 4 π ln 2 = 1 16 π 2 + 1 4 π ln 2 [ tan 1 v ln ( 1 + v 2 ) ] 0 1 + 0 1 ln ( 1 + v 2 ) 1 + v 2 d v = 1 16 π 2 + 0 1 4 π ln ( sec 2 θ ) d θ = 1 16 π 2 2 0 1 4 π ln ( cos θ ) d θ = 1 16 π 2 + 1 2 π ln 2 G \begin{aligned} J & = \; \Big[v\big(\tan^{-1}v\big)^2\Big]_0^1 - \int_0^1 \frac{2v \tan^{-1}v}{1+v^2}\,dv + \tfrac14\pi\ln2 \\ & = \; \tfrac{1}{16}\pi^2 + \tfrac14\pi\ln2 - \Big[\tan^{-1}v\,\ln(1+v^2)\Big]_0^1 + \int_0^1 \frac{\ln(1+v^2)}{1+v^2}\,dv \\ & = \; \tfrac{1}{16}\pi^2 + \int_0^{\frac14\pi}\ln(\sec^2\theta)\,d\theta \; = \; \tfrac{1}{16}\pi^2 - 2\int_0^{\frac14\pi}\ln(\cos\theta)\,d\theta \\ & = \; \tfrac{1}{16}\pi^2 + \tfrac12\pi \ln 2 - G \end{aligned} where G G is the Catalan constant.


Similarly, but more simply, we have K = 0 1 0 1 tan 1 y x d x d y = 1 2 0 d v 0 m i n ( v , v 1 ) d u v 1 tan 1 v = 1 2 0 1 tan 1 v d v + 1 2 1 v 2 tan 1 v d v = 1 2 0 1 ( tan 1 v + 1 2 π tan 1 v ) d v = 1 4 π \begin{aligned} K & = \; \int_0^1 \int_0^1 \tan^{-1}\tfrac{y}{x}\,dx\,dy \; = \; \tfrac12\int_0^\infty\,dv \int_0^{\mathrm{min}(v,v^{-1})}\,du \,v^{-1}\,\tan^{-1}v \\ & = \; \tfrac12\int_0^1 \tan^{-1}v\,dv + \tfrac12\int_1^\infty v^{-2}\tan^{-1}v\,dv \\ & = \; \tfrac12\int_0^1 \left(\tan^{-1}v + \tfrac12\pi - \tan^{-1}v\right)\,dv \\ & =\; \tfrac14\pi \end{aligned}


BTW Wolfram Alpha may not be able to handle evaluating J J , but Mathematica makes short work of it.

Mark Hennings - 8 months ago

Log in to reply

@Mark Hennings Be right back. I have to refill my printer, in the middle of this pandemic.

Pi Han Goh - 8 months ago

@Mark Hennings I want to say that I totally forgot about using Jacobian, but I'm pretty I can't finish it as you have done it.

You have my utmost gratitude again.

Would you like to post this variance question? Or would you like me to do it?

Pi Han Goh - 8 months ago

Log in to reply

@Pi Han Goh We're also going to have to work out the double integral of tan 1 ( y x ) tan 1 ( 1 y x ) \tan^{-1}(\tfrac{y}{x}) \tan^{-1}(\tfrac{1-y}{x}) . I haven't done that one yet...

Mark Hennings - 8 months ago

@Mark Hennings Simply wow!!!! @Mark Hennings . A variable change did not cross my mind even for once.

Arghyadeep Chatterjee - 8 months ago

this value seems to be π \pi minus the value you found - any idea which one of us went wrong where?

Yeah, I'm still reading through this. I can't spot any error.... yet.

Pi Han Goh - 8 months ago

Log in to reply

Wait... to be honest, I still don't understand your solution.

Pi Han Goh - 8 months ago

Log in to reply

@Pi Han Goh Never mind, I found my mistake - I had

θ = tan 1 x y + tan 1 x 1 y \theta=\tan^{-1}\frac{x}{y}+\tan^{-1}\frac{x}{1-y}

when I should have had θ = tan 1 y x + tan 1 1 y x \theta=\tan^{-1}\frac{y}{x}+\tan^{-1}\frac{1-y}{x}

It's close, though! Editing now...

Chris Lewis - 8 months ago

Log in to reply

@Chris Lewis Right, I've edited my comment and we do get the same answer.

Sorry I wasn't clear. What I was trying to do was think about the probability a bit geometrically. The locus of points giving the same θ \theta value divides the square into two regions; one (green) where the angle A P B APB is bigger than θ \theta , and one where it's smaller (blue). The probability of being in one of these regions is equal to the area of that region (since the probability space has unit area).

At the median θ \theta value, these two regions will each have area 1 2 \frac12 (by definition of the median). So if we can find the area, we get an equation for θ \theta . The good news is, the locus is part of a circle; the bad news is, it's a segment, so the solution has to be numerical.

I hope that makes sense!

Chris Lewis - 8 months ago

Delightful. Do you want me to post the median question? Or would you like to do it yourself? (I still can't understand your solution... yet)

Pi Han Goh - 8 months ago

@Chris Lewis , see this link . Feel free to paste this as your own problem statement for the median.

Pi Han Goh - 8 months ago

Log in to reply

Thanks - although you came up with this problem (and wrote it up, too)! I'd say either post it yourself or perhaps this could be part of a discussion? (You've had some cool ideas to explore here, but I'm worried they'll get a bit lost in these comments/replies).

Chris Lewis - 8 months ago

@Mark Hennings

Hahahha, I've made a booboo. It turns out that if we want to know the variance, we ALSO need to know the value of 0 1 0 1 tan 1 ( y x ) tan 1 ( y 1 x ) d y d x \int \limits_0^1 \int \limits_0^1 \tan^{-1} (\tfrac yx) \tan^{-1} (\tfrac y{1-x} ) \, dy \,dx , which is approximately 0.6282218 > π 5 0.6282218 > \frac\pi5 .

Let me see if I can work this out by myself first.

Pi Han Goh - 8 months ago

Log in to reply

To clarify, the angle A P B : = θ = π tan 1 ( y x ) tan 1 ( y 1 x ) \angle APB := \theta = \pi - \tan^{-1} (\tfrac yx) - \tan^{-1} (\tfrac y{1-x} ) . We have already discovered its expected value to be π / 2 \pi/2 .

To find its variance, we are left to find its second moment. That is, 0 1 0 1 θ 2 d y d x \int \limits_0^1 \int \limits_0^1 \theta^2 \, dy \, dx . Expanding this gives

π + 2 0 1 0 1 [ tan 1 ( y x ) ] 2 d y d x 4 π 0 1 0 1 [ tan 1 ( y x ) ] d y d x + 2 0 1 0 1 [ tan 1 ( y x ) tan 1 ( y 1 x ) ] d y d x \pi + 2 \int_0^1\int_0^1\left [\tan^{-1} (\tfrac yx) \right]^2 \, dy \, dx - 4\pi \int_0^1\int_0^1 \left [\tan^{-1} (\tfrac yx) \right] \, dy \, dx + 2 \int_0^1\int_0^1 \left [\tan^{-1} (\tfrac yx) \tan^{-1} (\tfrac y{1-x} ) \right] \, dy \, dx

The first two iterated integrals has already been computed to be π 2 16 + ln 2 2 π G \frac{\pi^2}{16} + \frac{\ln2}2 \pi - G and π 4 \frac\pi4 , respectively. What's left is the last integral, which Mathematica failed to tackle.

Pi Han Goh - 8 months ago

Log in to reply

@Pi Han Goh . I think I made a bad decision to write the angle expression as π a r c t a n ( y x ) a r c t a n ( y 1 x ) \pi-arctan(\frac{y}{x}) - arctan\left(\frac{y}{1-x}\right) . Simply writing it as a r c c o t ( x y ) + a r c c o t ( 1 x y ) arccot\left(\frac{x}{y}\right)+arccot\left(\frac{1-x}{y}\right) makes more sense.

Arghyadeep Chatterjee - 8 months ago

I created the below gif using GIFsmos to show the locus I was referring to above a bit more clearly. The red line on each frame corresponds to all the points P P in the square such that A P B = θ \angle APB=\theta , as θ \theta varies from 1 4 π \frac14\pi to π \pi :

The red region is the set of points such that A P B > θ \angle APB > \theta . Since we're equally likely to choose any point in the square, the area of the red region gives Pr ( A P B > θ ) \text{Pr}(\angle APB > \theta) . The complement of this is therefore the cumulative distribution function!

As above, it turns out the red line is part of a circle (centre ( 1 2 cot θ , 1 2 ) \left(\frac12 \cot \theta,\frac12\right) and radius 1 2 csc θ \frac12 \csc \theta ). The qualitative shape of the red region depends on θ \theta , as you can see in the animation; but it's not too hard to work out that ( Pr ( A P B θ ) = { 1 [ 3 cot θ 4 + θ tan 1 4 cot θ 3 2 cot θ ( cot θ 2 ) 4 cot θ 3 4 sin 2 θ ] if π 4 θ < 2 tan 1 1 2 1 cot θ 2 π 2 θ + sin 2 θ 8 sin 2 θ if 2 tan 1 1 2 θ < π 2 1 2 π 2 θ + sin 2 θ 8 sin 2 θ if π 2 θ < π (\text{Pr}(\angle APB \le \theta)=\begin{cases} &1-\left[\frac{3\cot \theta}{4}+ \frac{\theta-\tan^{-1} \sqrt{\frac{4\cot \theta-3}{2-\cot \theta}}-(\cot \theta - 2 )\sqrt{4\cot\theta-3}}{4\sin^2 \theta} \right] \text{ if } \frac{\pi}{4} \le \theta < 2\tan^{-1} \frac12 \\ &1-\cot\theta-\frac{2\pi-2\theta + \sin 2\theta}{8\sin^2 \theta} \text{ if } 2\tan^{-1} \frac12 \le \theta < \frac{\pi}{2} \\ &1-\frac{2\pi-2\theta + \sin 2\theta}{8\sin^2 \theta} \text{ if } \frac{\pi}{2} \le \theta<\pi \end{cases}

(If I can simplify this further I will!)

The cumulative distribution and probability density (found by differentiating the cdf) look like this:

The cdf lets us solve for the median; as above, we get θ = 1.38 \theta=1.38\ldots .

The pdf lets us solve for the mode; it seems (proof to come, I hope) that this occurs at θ = 2 tan 1 1 2 \theta=2\tan^{-1}\frac12 (this is the value where the circle is tangent to the side of the square x = 1 x=1 ).

If anyone could help get these expressions a bit neater I'd appreciate it! Wolfram|Alpha did some simplification, but didn't manage to compute the second derivative of the cdf everywhere.

Chris Lewis - 7 months, 4 weeks ago

Log in to reply

This is amazing work. I'm still digesting this since yesterday. And I'm still struggling with your solution for my median question.

Will update that you once I got something useful.

Pi Han Goh - 7 months, 4 weeks ago

Log in to reply

Thanks! I wonder if it might be useful for the variance question too (though I suspect not - I think the way you're going with integrating over the square is more likely to work). If you've any specific questions let me know and I'll try to make it clearer.

Chris Lewis - 7 months, 3 weeks ago

I doubt it will get much less complicated. I have, in principle, an explicit expression for the variance of θ \theta , but it is horrendous! I need, amongst other things, the integral 0 1 tan 1 x tan 1 ( 1 x ) d x \int_0^1 \tan^{-1}x \tan^{-1}(1-x)\,dx which evaluates in terms of arctrig functions, logarithms and polylogarithms. I have not (yet) managed to simplify this down to something that can be lived with

Mark Hennings - 7 months, 3 weeks ago

Let us consider AB to be the x-axis \text{x-axis} . Now let the point be ( x , y ) (x,y) where x and y are uniformly and independently distributed on ( 0 , 1 ) (0,1) . Hence our Probability Density Function is just:- f ( x , y ) = 1 when 0 < x < 1 , 0 < y < 1 f(x,y) = 1 \,\,\,\,\text{when}\, 0<x<1\,\,\,\,,0<y<1 and 0 0 elsewhere .

Now the A P B = π tan 1 ( y x ) tan 1 ( y 1 x ) \displaystyle \angle APB = \pi - \tan^{-1}\left(\frac{y}{x}\right) - \tan^{-1}\left(\frac{y}{1-x}\right) in radians.

Hence the expected value is :-

0 1 0 1 ( π tan 1 ( y x ) tan 1 ( y 1 x ) ) d y d x \displaystyle \int_{0}^{1}\int_{0}^{1}\left(\pi - \tan^{-1}\left(\frac{y}{x}\right) - \tan^{-1}\left(\frac{y}{1-x}\right)\right)\,dy\,dx .

Now the definite integral of tan 1 ( y x ) \tan^{-1}\left(\frac{y}{x}\right) and tan 1 ( y 1 x ) \tan^{-1}\left(\frac{y}{1-x}\right) over 0 < x < 1 0<x<1 will have same value due to symmetry......one can even substitute z = 1 x z=1-x to show that the second integral is indeed the same as the first integral.

So we have :-

0 1 0 1 ( π 2 tan 1 ( y x ) ) d y d x \displaystyle \int_{0}^{1}\int_{0}^{1}\left(\pi - 2\cdot \tan^{-1}\left(\frac{y}{x}\right)\right)\,dy\,dx .

Now we can substitute y = t x y=tx such that d y = x d t dy=xdt so that our integral becomes easier to compute.

We have 0 1 0 1 tan 1 ( y x ) d y d x = 0 1 0 1 x x tan 1 ( t ) d t d x \displaystyle \int_{0}^{1}\int_{0}^{1}\tan^{-1}\left(\frac{y}{x}\right)\,dy\,dx = \int_{0}^{1}\int_{0}^{\frac{1}{x}}x\tan^{-1}(t)\,dt\,dx .

We know tan 1 ( x ) d x = x tan 1 ( x ) 1 2 ln ( 1 + x 2 ) + C \int \tan^{-1}(x)\,dx = x\tan^{-1}(x) - \frac{1}{2}\ln\left(1+x^{2}\right) + C .

So we have 0 1 ( tan 1 ( 1 x ) x 2 ln ( 1 + 1 x 2 ) ) d x = 0 1 ( π 2 cot 1 ( x ) x 2 ln ( 1 + 1 x 2 ) ) d x \displaystyle \int_{0}^{1}\left(\tan^{-1}\left(\frac{1}{x}\right) - \frac{x}{2}\ln\left(1+\frac{1}{x^{2}}\right)\right)\,\,dx =\int_{0}^{1}\left(\frac{\pi}{2}-\cot^{-1}(x) - \frac{x}{2}\ln\left(1+\frac{1}{x^{2}}\right)\right)\,\,dx

Now we know cot 1 ( x ) d x = x cot 1 ( x ) + 1 2 ln ( 1 + x 2 ) + C \int \cot^{-1}(x)\,dx = x\cot^{-1}(x) + \frac{1}{2}\ln(1+x^{2}) + C .

Also the integral involving the natural logarithm ( ln ) (\ln) can be evaluated using substitution x 2 = u x^{2}=u so it becomes of the form ln ( u + 1 ) ln ( u ) d u \int \ln(u+1) - \ln(u) \,\,du

Hence using these results we arrive at the conclusion that 0 1 0 1 tan 1 ( y x ) d y d x = π 4 \displaystyle \int_{0}^{1}\int_{0}^{1}\tan^{-1}\left(\frac{y}{x}\right)\,dy\,dx = \frac{\pi}{4}

Hence our expected value is π 2 π 4 = π 2 = 90 ° \displaystyle \pi - 2\cdot\frac{\pi}{4} = \frac{\pi}{2} = \ang{90}

Perfect. I was looking for a calculus solution and I gave up after 1 week. But you pulled it off! DELIGHTFUL!!!!!!

Let me work on the variance of the angle formed (angle APB), because I'm a sadist.

Pi Han Goh - 8 months ago

Log in to reply

OMG....variance!!!! Now that would be a challenge. I cannot even begin to think how am I going to solve the square of that integrand...lol

Arghyadeep Chatterjee - 8 months ago

Log in to reply

If it helps, I've done a Monte-Carlo simulation in Python and I get a (sample) variance of about 0.368

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from random import random as rd 
from math import hypot, acos
from statistics import mean, variance

total_number_of_trials = int(1e5) ; results_drawn = []

for _ in range(total_number_of_trials):
    random_coordinate = [ rd(), rd() ]
    distance_x = hypot(random_coordinate[0], 1 - random_coordinate[1] )
    distance_y = hypot(random_coordinate[0], random_coordinate[1] )
    angle_apb = acos( ((distance_x **2) + (distance_y ** 2) - 1)/(2 * distance_x * distance_y) )
    results_drawn.append(angle_apb)

print(f"Monte Carlo simulation with {total_number_of_trials:,} trials:\n")
print("Mean:\t\t\t" , mean(results_drawn))
print("Sample variance:\t" , variance(results_drawn))

'''Output:

Monte Carlo simulation with 100,000 trials:

Mean:                    1.5725497504309007
Sample variance:         0.36845407628732413
'''

Pi Han Goh - 8 months ago

Log in to reply

@Pi Han Goh My result agrees with Mathematica

Pi Han Goh - 8 months ago

Log in to reply

@Pi Han Goh It appears that Mathematica can't evaluate this integral at all. So I'm pretty pessimistic to find a closed-form for V a r [ A P B ] \mathsf{Var}[\angle APB] .

Pi Han Goh - 8 months ago

Log in to reply

@Pi Han Goh It all boils down to computing 0 1 0 1 ( arctan ( y x ) ) 2 d y d x \int \limits_0^1 \int \limits_0^1 ( \arctan( \frac yx ) )^2 \, dy \, dx

Pi Han Goh - 8 months ago

Log in to reply

@Pi Han Goh @Pi Han Goh yeah exactly....it is hopeless to try and find the closed form of the variance. Either monte carlo or numerically approximating the integral is the only hope sadly.

Arghyadeep Chatterjee - 8 months ago

Log in to reply

@Arghyadeep Chatterjee What about the mode and the median? heheheheheehehe

Pi Han Goh - 8 months ago

Log in to reply

@Pi Han Goh My MC above shows that the median is about 1.384 .

Pi Han Goh - 8 months ago

Log in to reply

@Pi Han Goh Mode should not be very hard to find. It is a maxima problem for two variables but median will be tough to do by hand.

Arghyadeep Chatterjee - 8 months ago

Log in to reply

@Arghyadeep Chatterjee My MC above shows MODE approx 1.253 .

I'm still working on this.

Pi Han Goh - 8 months ago

Log in to reply

@Pi Han Goh @Arghyadeep Chatterjee , see Mark Hennings' comment under Chris Lewis' solution.

Pi Han Goh - 8 months ago
Pi Han Goh
Sep 7, 2020

Disclaimer: This is incomplete.


Let A ( 1 , 0 ) , B ( 0 , 0 ) , P ( r 1 , r 2 ) A(1,0), B(0,0) , P(r_1, r_2) , where r 1 , r 2 r_1, r_2 are two identical identical random variable that follows the uniform distribution U ( 0 , 1 ) \mathcal U \sim (0,1) .

Using cosine rule , we have A P B = cos 1 ( ( A P ) 2 + ( B P ) 2 ( A C ) 2 A P B P ) \angle APB = \cos^{-1}\left(\dfrac{(AP)^2 + (BP)^2 - (AC)^2}{AP \cdot BP} \right) .

With A B = 1 AB = 1 , and A P , B P AP,BP can both be measured using the distance formula .

Then, A P B \angle APB is

  • larger than 9 0 90^\circ if ( A P ) 2 + ( B P ) 2 1 < 0 (AP)^2 + (BP)^2 - 1 < 0

  • smaller than 9 0 90^\circ if ( A P ) 2 + ( B P ) 2 1 > 0 (AP)^2 + (BP)^2 - 1 > 0

Substitute and simplify, we have ( A P ) 2 + ( B P ) 2 1 2 = r 1 2 + r 2 2 r 1 r 2 = r 1 3 r 2 3 r 1 r 2 \frac{(AP)^2 + (BP)^2 - 1}2 = r_1^2 + r_2^2 - r_1 r_2 = \dfrac{r_1^3 - r_2 ^3}{r_1 - r_2 } (as the probability of r 1 r 2 = 0 r_1 - r_2 = 0 is 0).

In other words,

  • A P B > 9 0 \angle APB > 90^\circ if r 1 < r 2 r_1 < r_2 .

  • A P B < 9 0 \angle APB < 90^\circ if r 1 > r 2 r_1 > r_2 .

Since P r [ r 1 > r 2 ] = P r [ r 1 < r 2 ] = 1 2 \mathsf{Pr}[r_1 > r_2] = \mathsf{Pr}[r_1 < r_2] = \frac12 , it is equally likely that the angle A P B \angle APB is larger or smaller than 9 0 90^\circ . Hence, the expected value in question is 9 0 \boxed{90^\circ} .


You might notice that my solution is flawed because I didn't justify that the probability density function of θ \theta is symmetric at θ = 9 0 \theta = 90^\circ .

Yes, cosine rule!! Nice thinking, should have thought of that as standard approach for two different lengths in rectangle as well...

Mahdi Raza - 9 months, 1 week ago

How about put the figure into the co-ordinate plan? Setup the equation of the two lines pass thru A ( 0 , 0 ) , B ( 0 , 1 ) A(0,0), B(0,1)

Then the product of the slopes m × n = y ( y 1 ) x 2 m \times n = \cfrac{y(y-1)}{x^2}

As x , y x, y ~ U ( 0 , 1 ) U(0,1) and x , y x, y are iid (independent and identically), E ( m × n ) = 1 E(m \times n ) = -1 \implies the expected angle = 90 ° = 90 \degree

For rectangle cases, we may use same method to find out the value. Just aware the size length is smaller length or longer length (x,y) of rectangle.

Pop Wong - 9 months, 1 week ago

Log in to reply

@Pop Wong See my solution.

Arghyadeep Chatterjee - 8 months ago

Wolframalpha

Yuriy Kazakov - 5 months, 1 week ago

Log in to reply

NiCEEEEEEEEEEEE. How do we do evaluate that integral by hand?

Pi Han Goh - 5 months, 1 week ago

Log in to reply

I don’t know 🤔

Yuriy Kazakov - 5 months, 1 week ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...