Puzzle: Length of a line between two random points on the rim of a square

A probability puzzle I saw online somewhere and solved on a plane ride: choose two random points along the rim of an \(l\times l\) square. What is the probability that the line connecting them is longer than \(l\)?

A solution

Since a square’s edge is identical to the three others we can (wlog) suppose that the first point is on the leftmost edge. As a further simplification we can (wlog) scale all lengths by \(1/l\) and just focus on the unit square. There are three cases I want to condition on for the second point: i) it lands on the same edge; ii) it lands on an adjacent edge; and iii) it lands on an opposite edge.

There is one opposite edge and two adjacent edges, so we have \(P(\mathrm{opposite}) = P(\mathrm{same}) = 1/4,\) and \(P(\mathrm{adjacent}) = 1/2.\)

When both points lie on the same edge there is no probability for the line between them to be longer than \(1\). On the other hand if the points are on opposite edges there is no probability that the line between them is shorter than \(1\). This leaves the adjacent case as the only interesting one.

For the two adjacent cases we again have a symmetry so that we can assume (wlog) that it’s the bottom edge that our second point lands on. We adopt a coordinate system so that the lower left corner is the origin and the situation looks like the figure below.

We’re looking for the length, \(x\), of the hypotenuse of a right triangle with sides of length \(p_1\) and \(p_2\). These are chosen uniformly at random in \([0,1]\). We’re looking for

\[ \begin{align*} P(x > 1) &= P(\sqrt{p_1^2 + p_2^2)} > 1) \\ &= P(p_1^2 + p_2^2 > 1) \\ &= 1 - P(p_1^2 + p_2^2 \leq 1). \end{align*} \]

This describes a very pretty geometrical situation. If we look at the unit square comprising all possible pairs, \((p_1, p_2)\), the cases where \(p_1^2 + p_2^2 \leq 1\) are exactly those inside of the quarter unit circle contained in our unit square:

In other words \(1 - P(p_1^2 + p_2^2 \leq 1) = 1 - \pi/4.\) So finally, if \(L\) is the event that the line connecting our two points is longer than 1 we have

\[ \begin{align*} P(L) &= \frac{1}{4}P(L | \mathrm{same}) + \frac{1}{4}P(L | \mathrm{opposite}) + \frac{1}{2}P(L | \mathrm{adjacent}) \\ &= \frac{1}{4} + \frac{1}{2}(1 - \pi/4) \\ &= \frac{1}{8}(6 - \pi) \\ &\approx 0.357. \end{align*} \]

this file last touched 2023.12.23