Solution
Average Distance in a Square
Show the problem again
Two points are chosen independently and uniformly at random in the unit square [0, 1] × [0, 1]. What is the expected Euclidean distance between them? Give the answer rounded to 4 decimal places.
Worked solution
The answer is (2 + √2 + 5 ln(1 + √2))/15 ≈ 0.5214. The coordinate differences U = |x₁ − x₂| and V = |y₁ − y₂| are independent with density 2(1 − u) on [0, 1] (the density of the distance between two uniform points on a segment). So E[d] = ∫₀¹∫₀¹ 4(1 − u)(1 − v) √(u² + v²) du dv. By symmetry in u and v, integrate over the triangle v ≤ u and double. In polar coordinates (u = r cos θ, v = r sin θ, 0 ≤ θ ≤ π/4, 0 ≤ r ≤ sec θ), the inner integral of 4(1 − r cos θ)(1 − r sin θ) r² dr is a polynomial in sec θ and tan θ. Integrating those powers of sec θ over [0, π/4] produces √2 terms and the term ln(1 + √2) = ∫₀^{π/4} sec θ dθ, giving the closed form above. A Monte Carlo check with a few million samples agrees to four decimals.
Source: Classic square line picking problem; the closed form is standard in geometric probability. Statement written for AxiomIQ.