# Probability of intersection of square and circle

Suppose a square of length $p$ and a circle of diameter $q$ are taken on $x$-axis, i.e. a side of the square lies on $x$-axis, and the diameter of the circle lies on the $x$-axis. The figures are drawn between the points $(0, 0)$ and $(m, 0)$, where $m$ is a positive real. So this implies $0 \leq p,q \leq m$.

What is the probability that the square and the circle intersect?

-
The square and the circle are placed independently, and uniformly? When you say figures are drawn between points $(0,0)$ and $(m,0)$, do you mean that entire objects fit within the strip $0<x<m$? –  Sasha Apr 2 '13 at 16:36

I assume that the position of both is chosen uniformly on $[0,m]$ and independently from each other. Thus consider the random variables $V,W$ where $V$ denotes the beginning point of the side of the square that lies on the $x$-axis and $W$ the left intersection point of the circle and the $x$-axis (I will refer to those points as the beginning point of the respective object). By assumption we have $V\sim U[0,m-p]$ and $W\sim U[0,m-q]$. There are three cases:

1) $V<W$, i.e. the beginning point of the square is left of the beginning point of the circle

2) $V>W$, i.e. the opposite

3) $V=W$.

In the first case the objects intersect, if $W-(V+p)<0$, i.e. the beginning point of the circle lies on the side of the square. Analogously we see that there is an intersection in the second case if $V-(W+q)<0$. In the third case there is an intersection. So you are looking for

$$P(V<W, W-(V+p)<0) + P(V>W, V-(W+q)<0)+P(V=W)$$ Consider the first summand $$P(V<W, W-(V+p)<0) = \int_{0}^{m-q} \frac{1}{m-q} \int_{\max(w-p,0)}^{m-p} \frac{1}{m-p} dv \, dw\\ = \frac{1}{(m-q)(m-p)} \int_0^{m-q}m-p-\max(w-p,0) \,dw \\ = \frac{1}{(m-q)(m-p)}\left((m-p)p + m(m-q-p) -\frac{1}{2}(m-q)^2 -\frac{1}{2}p^2 \right) \\ =\frac{m^2-p^2-q^2}{2(m-q)(m-p)}$$ You can do the 2nd summand just like this.

For the 3rd I calculate $$P(V=W) = \int_0^{\min(m-p,m-q)} \frac{1}{m-q} \int_{\{w\}}\frac{1}{m-p} dv\,dw = 0$$ since $V$ is a continuous distribution.

-