# Probability that rectangle is inside a circle

We randomly uniformly pick point $x$ on a unit circumference $\{x^2 + y^2 = 1\}$. Then we randomly uniformly pick point $y$ on a unit circle $\{x^2 + y^2 \leq 1\}$. Let $R$ be a rectangle with diagonal $xy$, which sides are parallel to coordinate axes. What is the probability that $R$ lies completely inside the unit circle?

We see, that after $x$ is chosen we have a rectangle $A$, within which our point $y$ should fall to satisfy the condition of the task.

The area of the rectangle $A$ equals $S_A(x) = 4 \sin{(2x)}$ and the probability $P(\{y \in A\}) = \frac{S_A}{S_{circle}} = \frac{S_A}{\pi}.$ How can I find this probability?

The problem for me is that $S_A(x)$ is the transformation of random variable $x \sim unif(0, \frac{\pi}{2})$. For some reason I think that the answer is $\frac{\mathbb{E}[S_A(x)]}{\pi} = \frac{1}{\pi} \cdot \frac{1}{\pi/2 - 0} \cdot \int_0^{\pi/2}S_A(x)dx$, but I do not know why I think so.

• Where did this problem come from? – Franklin Pezzuti Dyer May 30 '17 at 13:37
• @Frpzzd It's from an old entrance exam to MS CS program in some russian university – Wunsch Punsch May 30 '17 at 13:44
• Do you have a way to access the answer? I just posted my answer, but I'm not sure if it is correct. – Franklin Pezzuti Dyer May 30 '17 at 13:49

For a given position of $X$, say at coordinates $(\cos\theta,\sin\theta)$ in the first quadrant, the area of the rectangle is indeed

$$A=4\sin\theta\cos\theta.$$

As $Y$ is drawn uniformly in the disk, the probability to fall in $A$ is $A/\pi$.

Then as $X$ is drawn uniformly on the circumference and independently of $Y$, you take the expectation on the first quadrant,

$$P=\frac4\pi\frac 2\pi\int_{\theta=0}^{\pi/2}\sin\theta\cos\theta\,d\theta=\frac4{\pi^2}.$$

• Our answers to this question seem to conflict. Can you find a fault in my answer? You're probably right (I'm not that experienced with probability using integrals) but I would like to know what I did wrong. – Franklin Pezzuti Dyer May 30 '17 at 14:31
• @Frpzzd: you did not normalize the weight in your final integral. – user65203 May 30 '17 at 14:32
• Oh... so I need to add a $\frac{2}{\pi}$. I see. Thank you! I'll change it. – Franklin Pezzuti Dyer May 30 '17 at 14:35
• @YvesDaoust Why do we take an expectation? Why do we care about expectation at all? – Wunsch Punsch May 30 '17 at 14:37
• @WunschPunsch: because we are interested in the answer. – user65203 May 30 '17 at 15:14

Let the coordinates of the first point be $(x_0,y_0)$ and those of the second point be $(x_1, y_1)$. Then the coordinates of the other two points on the rectangle are $(x_0, y_1)$ and $(x_1, y_0)$.

Let us suppose the first point must fall on the quarter-circle in the first quadrant. This does not affect the probability at all because of the symmetry of the circle. Then we have $y_0=\sqrt{1-x_0^2}$. In order to have the rectangle fully inside of the circle, all of the following must be true: $$x_0^2+y_1^2 \le 1$$ $$x_1^2+y_0^2 \le 1$$ We can substitute into the second requirement $y_0=\sqrt{1-x^2}$ to get $$x_1^2+1-x_0^2 \le 1$$ $$x_1^2-x_0^2 \le 0$$ $$x_0^2 \ge x_1^2$$ $$|x_0| \ge |x_1|$$ Similarly, the first requirement can be replaced by $$|y_0| \ge |y_1|$$ and our requirements are $$|x_0| \ge |x_1|$$ $$|y_0| \ge |y_1|$$ Try and visualize this:

Let $F$ be the event in which the rectangle fits, and $P(F|x_0)$ be the probability that the rectangle falls entirely inside of the circle given the value of $x_0$. All points $(x_1, y_1)$ for which the rectangle would fit in the circle are inside of the green rectangle shown with width $2x_0$ and height $2y_0$. This is now a spatial probability problem. Given $x_0$, we can now say that the probability of the rectangle fitting is the probability that $(x_1, y_1)$ lands in that green rectangle. This probability is given by the area of the rectangle over the area of the circle: $$P(F|x_0)=\frac{4x_0y_0}{\pi}$$ $$P(F|x_0)=\frac{4x_0\sqrt{1-x_0^2}}{\pi}$$ We will have to integrate over this to find the total probability. Our first instinct would be to try $$\int_{-1}^{1} P(F|x_0)dx_0$$ but this counts the points on the circumference of the circle unevenly, and not with equal probability. Instead, we should try $$\int_{0}^{\frac{\pi}{2}} P(F|\cos x_0)dx_0$$ Because this sweeps the circumference of the quarter-circle counting all points equally. Thus the probability should be $$\frac{2}{\pi}\int_{0}^{\frac{\pi}{2}} \frac{4\cos x_0\sqrt{1-\cos^2 x_0}}{\pi}dx_0$$ We can simplify this to $$\frac{2}{\pi}\int_{0}^{\frac{\pi}{2}} \frac{4\cos x_0|\sin x_0|}{\pi}dx_0$$ This value turns out to be about $0.405$.

• Assume that the probability was $1$ instead of $4x_0y_0/\pi$. Your last integral would yield $\pi/2$ !? – user65203 May 30 '17 at 14:31
• @Frpzzd 1) No, I do not have answers 2) Why do we integrate $P(F|\cos{x_0})$ instead of $P(F|x_0)$? Our $x_0 \sim unif(0,1)$ (because it is in the first quadrant). What do you mean saying, that $\int_0^1 P(F|x_0) dx_0$ counts points on circumference unevenly? – Wunsch Punsch May 30 '17 at 14:51
• Here is an example of how it counts the points unevenly. Suppose you took a quarter circle and sliced it with the line $x=\frac{1}{2}$. A longer length of circumference would lie to the right of the line than to the left. However, if we sliced it with the line $y=x$, it divides the quarter circle into two arcs of equal length. When we integrate from $0$ to $1$, it is like we are "wiping" a vertical line over the circle... but this does not cut the circle evenly! Instead, we must "wipe" over the circle with an angle at the origin. – Franklin Pezzuti Dyer May 30 '17 at 14:55

Due to symmetry, without loss of generality the point on circumference is uniformly selected to by in the first quadrant, that is it makes an angle $\theta$, uniform in $(0,\pi/2)$.

The $x$-component of this point is then $X_0= \cos \theta$ and the $y$-component is $Y_0=\sin \theta$.

As for the second point, write $X$ and $Y$ for its $x$- and $y$- components, respectively. In order for the rectangle to be contained in the circle, we must have $(X,Y) \in [-X_0,X_0]\times [-Y_0,Y_0]$.

Because $(X,Y)$ is uniform in the disk, and is independent of $\theta$, conditioning on $\theta$, the probability of $(X,Y)$ landing in this rectangle is the area of this rectangle divided by $\pi$. That is,

$$\frac{ 2 \cos \theta \times 2 \sin \theta}{\pi} = \frac{ 2 \sin (2\theta) }{\pi}.$$

Integrate with respect to $\theta$ to get the answer:

$$p= \frac{2}{\pi} \int_0^{\pi/2} \frac{ 2\sin (2\theta)}{\pi}d\theta= \frac 2{\pi^2} \int_0^{\pi}\sin(u)du =\frac{4}{\pi^2}.$$

• I believe that you should have integrated from $0$ to $\frac{\pi}{2}$ instead of $0$ to $\pi$. – Franklin Pezzuti Dyer May 30 '17 at 15:18
• I changed $u=2\theta$, but didn't account for that... Will fix now. Thanks. – Fnacool May 30 '17 at 15:19