Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 117

Outrun the Angry Ram

You are tucked into the southeast corner of a square, fenced paddock. Two gates are equidistant from you, one at the southwest corner and one at the northeast corner. An angry ram charges in through the southwest gate and runs directly at you at constant speed, always pointing straight at wherever you are now. You run at constant speed north along the eastern fence toward the northeast gate. How much faster than you must the ram run so that it catches you exactly as you reach the gate?

The Riddler, FiveThirtyEight(original post)

Solution

A pursuit curve looks forbidding, but one bookkeeping trick avoids solving it. Track two running totals over the chase, the distance between ram and farmer, and how far north the ram has climbed, and tie them together through the single angle along which the ram is always looking.

Fix the farmer’s speed at 11 and the side of the square at 11. Put the southwest gate (where the ram starts) at the origin, the farmer’s southeast corner at (1,0)(1,0), and the northeast gate at (1,1)(1,1). The farmer runs north up the line x=1x=1 at speed 11, so he reaches the gate at time t=1t=1. Let the ram’s speed be VV. “Caught exactly at the gate” means that at t=1t=1 the ram is also at (1,1)(1,1), so the gap between them has just closed to zero.

Let θ(t)\theta(t) be the angle between the ram’s heading, which always points straight at the farmer, and due north. Two facts follow from that single angle.

How the gap changes. Call the distance between ram and farmer DD. The ram slides along the line of sight toward the farmer at speed VV, which shrinks DD. The farmer, running north at speed 11, moves away along that same line of sight at the rate cosθ\cos\theta, which grows DD. So dDdt=V+cosθ.\frac{dD}{dt} = -V + \cos\theta . Integrating from t=0t=0 to t=1t=1, and using that the gap starts at D(0)=1D(0)=1 (southwest corner to southeast corner) and ends at D(1)=0D(1)=0, 01cosθdt=01 ⁣(dDdt+V)dt=(D(1)D(0))+V=V1.\int_0^1 \cos\theta\,dt = \int_0^1\!\Bigl(\tfrac{dD}{dt} + V\Bigr)dt = \bigl(D(1)-D(0)\bigr) + V = V - 1 .

How far north the ram climbs. The ram moves at speed VV along a heading θ\theta from north, so its northward speed is VcosθV\cos\theta, and its total climb is 01Vcosθdt=V(V1).\int_0^1 V\cos\theta\,dt = V\,(V-1). But the ram climbs from the southwest gate at height 00 to the northeast gate at height 11, a net rise of exactly 11. Setting the two expressions for that rise equal, V(V1)=1    V2V1=0    V=1+521.618.\begin{aligned} V(V-1) = 1 \;&\Longrightarrow\; V^2 - V - 1 = 0\\ \;&\Longrightarrow\; V = \boxed{\dfrac{1+\sqrt5}{2} \approx 1.618}. \end{aligned} The ram needs to be at least the golden ratio times your speed to run you down at the gate.

The computation

Re-run the chase and search for the speed that turns escape into capture. Step the farmer north at unit speed, step the ram straight toward him at speed VV, and record whether the ram reaches him before t=1t=1 (capture) or not (escape). Binary-search VV across that boundary.

  1. Place the farmer at (1,t)(1,t) and the ram at (0,0)(0,0); advance in tiny time steps.

  2. Each step, move the ram a distance VdtV\,dt along the unit vector toward the farmer.

  3. Capture if the gap closes before t=1t=1; escape otherwise.

  4. Bisect VV between an escaping and a capturing value.

import math

def escapes(V, dt=1e-5):
    rx, ry, t = 0.0, 0.0, 0.0
    while t < 1.0:
        dx, dy = 1.0 - rx, t - ry          # farmer at (1, t)
        d = math.hypot(dx, dy)
        if d < 1.5 * V * dt:               # ram reaches farmer
            return False
        rx += V * dt * dx / d
        ry += V * dt * dy / d
        t += dt
    return True                            # farmer reached the gate first

lo, hi = 1.0, 3.0
for _ in range(40):
    mid = (lo + hi) / 2
    lo, hi = (mid, hi) if escapes(mid) else (lo, mid)
print("critical V :", round((lo + hi) / 2, 5))
print("golden phi :", round((1 + 5 ** 0.5) / 2, 5))
# critical V : 1.61801
# golden phi : 1.61803