Skip to content
Vamshi Jandhyala

Books · The Fiddler: Solutions

Chapter 29

Can You Irrigate the Garden?

A circular garden has radius 11 furlong. Your assistant picks two random points on the boundary and runs a straight hose between them. On average, how far is the centre of the garden from the nearest part of the hose?

The Fiddler, Zach Wissner-Gross, November 14, 2025(original post)

Two random boundary points make a chord at distance cosφ2\cos\tfrac\varphi2 from the centre, where φ\varphi is the central angle between them.

Solution

The hose is a chord, and the centre’s nearest point on it is the foot of the perpendicular, always on the chord. A chord whose endpoints subtend a central angle φ\varphi lies at distance cosφ2\cos\tfrac\varphi2 from the centre. The angle φ\varphi between two independent uniform boundary points is itself uniform; writing θ\theta for the (uniform) angular gap on [0,2π)[0,2\pi), the distance is cosθ2\bigl|\cos\tfrac\theta2\bigr|, so E[dist]=12π02πcosθ2dθ=1π0πcosudu=2π0.6366.E[\text{dist}] = \frac1{2\pi}\int_0^{2\pi}\Bigl|\cos\tfrac\theta2\Bigr|\,d\theta = \frac1\pi\int_0^{\pi}|\cos u|\,du = \frac2\pi \approx \boxed{0.6366}.

The computation

Lay random hoses: two uniform boundary points make a chord, and the centre’s nearest point on it is the foot of the perpendicular (clamped to the segment). Average that distance over millions of chords.

import numpy as np
rng = np.random.default_rng(0); M = 4_000_000
t1, t2 = rng.uniform(0, 2*np.pi, M), rng.uniform(0, 2*np.pi, M)
A = np.c_[np.cos(t1), np.sin(t1)]; B = np.c_[np.cos(t2), np.sin(t2)]
AB = B - A; t = np.clip(-np.sum(A*AB, 1)/np.sum(AB*AB, 1), 0, 1)
print(round(np.linalg.norm(A + t[:, None]*AB, axis=1).mean(), 5))   # ~0.6366 = 2/pi

Extra Credit

Now you plant a second peach tree at a uniformly random point inside the garden. On average, how far is that point from the nearest part of the hose?

Solution

A random interior point is typically farther from a random chord than the centre is, since it can sit well off to one side. The foot of the perpendicular may now fall beyond an endpoint, so the nearest point is sometimes an endpoint of the hose. Averaging over both the random chord and the random interior point, E[dist]0.742.E[\text{dist}] \approx \boxed{0.742}. (The source’s value is behind its paywall; this is my own, by simulation.)

The computation

The same chords, but now also draw a uniform interior point (radius U\sqrt U for the right density) and measure its distance to the nearest part of the hose, clamping the foot of the perpendicular to the segment.

rng = np.random.default_rng(1); M = 4_000_000
t1, t2 = rng.uniform(0, 2*np.pi, M), rng.uniform(0, 2*np.pi, M)
A = np.c_[np.cos(t1), np.sin(t1)]; B = np.c_[np.cos(t2), np.sin(t2)]
r = np.sqrt(rng.uniform(0, 1, M)); a = rng.uniform(0, 2*np.pi, M)
P = np.c_[r*np.cos(a), r*np.sin(a)]
AB = B - A; t = np.clip(np.sum((P - A)*AB, 1)/np.sum(AB*AB, 1), 0, 1)
print(round(np.linalg.norm(P - (A + t[:, None]*AB), axis=1).mean(), 4))   # ~0.742