Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 202

So You Want To Tether Your Goat. Now What?

Riddler Express

A father can sing the Unbirthday Song to his daughter on any day that is not her birthday, so the probability of being able to sing it to her on a random day is 364/365364/365. She enjoys singing it to other people too, and stops only when she meets someone whose birthday it is today. What is the expected length of her singing streak? More precisely: how many random people can she expect to sing to before it becomes more likely than not that the next person is a birthday match?

The Riddler, FiveThirtyEight, October 12, 2018(original post)

Solution

Assume independent uniform birthdays across 365365 days. The probability that a particular random person does not share today’s date is 364/365364/365. After singing to NN independent strangers, the probability that none of them was the birthday person today is (364365)N.\left(\frac{364}{365}\right)^{N}. The puzzle asks for the largest NN such that this probability still exceeds 1/21/2, that is, the streak length over which a no-match is still more likely than a match: (364365)N  >  12.\left(\frac{364}{365}\right)^{N} \;>\; \tfrac{1}{2}. Taking logarithms, N  <  ln(1/2)ln(364/365)  =  0.693150.0027435    252.65.N \;<\; \frac{\ln(1/2)}{\ln(364/365)} \;=\; \frac{-0.69315}{-0.0027435} \;\approx\; 252.65. At N=252N = 252 the survival probability is 0.5009>1/20.5009 > 1/2, and at N=253N = 253 it drops to 0.4995<1/20.4995 < 1/2. So the streak can carry on for N=252 people\boxed{N = 252 \text{ people}} before a birthday encounter becomes more likely than not. The continuous threshold ln(2)365253\ln(2) \cdot 365 \approx 253 explains the value: at one-event-per-day with rate 1/3651/365, a half-life lasts roughly 0.6933650.693 \cdot 365 trials.

The computation

Evaluate (364/365)N(364/365)^{N} exactly for NN around the crossing and read off the last NN above 1/21/2.

from fractions import Fraction
import math

p_no = Fraction(364, 365)
for N in [250, 251, 252, 253, 254]:
    val = float(p_no ** N)
    print(f"N={N}: (364/365)^N = {val:.6f}")
crossing = math.log(0.5) / math.log(364 / 365)
print(f"continuous crossing at N = {crossing:.4f}")
print(f"largest N with survival > 1/2: {math.floor(crossing)}")

The script prints 0.50090.5009 at N=252N = 252 and 0.49950.4995 at N=253N = 253, with continuous crossing at N252.65N \approx 252.65, confirming the answer.

Riddler Classic

A farmer owns a circular field of radius RR. He ties his goat to the fence (a point on the circle’s boundary) with a tether of length rr. For what tether length rr does the goat graze exactly half the field by area?

The Riddler, FiveThirtyEight, October 12, 2018(original post)

Solution

Place the field as the unit disc (radius R=1R = 1) centred at the origin. Anchor the goat at A=(1,0)A = (1, 0) on the boundary. The grazing region is the intersection of the unit disc and the disc of radius rr centred at AA. Call this intersection a circular lens. We want area of lens  =  12π.\text{area of lens} \;=\; \tfrac{1}{2} \pi.

Setting up the lens. The two circles intersect at points where x2+y2=1x^2 + y^2 = 1 and (x1)2+y2=r2(x - 1)^2 + y^2 = r^2. Subtracting gives x=1r2/2x = 1 - r^2/2, and the chord runs vertically at this xx. Call this chord \ell. Each circle’s contribution to the lens is the circular segment of that circle cut off by \ell on the side containing the other circle’s centre.

Segment formula. For a circle of radius ρ\rho whose centre lies at horizontal distance hh from a vertical chord, the segment area on the far side of the chord (the smaller piece if h>0h > 0) is Aseg(ρ,h)  =  ρ2cos1 ⁣(hρ)    hρ2h2.A_{\text{seg}}(\rho, h) \;=\; \rho^{2} \cos^{-1}\!\left(\frac{h}{\rho}\right) \;-\; h \sqrt{\rho^{2} - h^{2}}.

Both contributions. For the unit field circle (centre at 00), the chord sits at horizontal distance h1=1r2/2h_1 = 1 - r^2/2, so its segment area on the goat side is A1  =  cos1 ⁣(1r22)    (1r22)r2r44.A_{1} \;=\; \cos^{-1}\!\left(1 - \tfrac{r^{2}}{2}\right) \;-\; \left(1 - \tfrac{r^{2}}{2}\right) \sqrt{\,r^{2} - \tfrac{r^{4}}{4}\,}. For the goat circle (centre at A=(1,0)A = (1, 0) with radius rr), the chord sits at horizontal distance h2=1(1r2/2)=r2/2h_2 = 1 - (1 - r^2/2) = r^2/2 from AA, so its segment area on the field side is A2  =  r2cos1 ⁣(r2)    r22r2r44.A_{2} \;=\; r^{2} \cos^{-1}\!\left(\frac{r}{2}\right) \;-\; \frac{r^{2}}{2} \sqrt{\,r^{2} - \tfrac{r^{4}}{4}\,}. The lens is the sum A1+A2A_{1} + A_{2}. Setting this equal to π/2\pi/2 gives the implicit equation cos1 ⁣(1r22)+r2cos1 ⁣(r2)(1+r22) ⁣(1r22)r2r44  =  π2.\begin{align*} \cos^{-1}\!\left(1 - \tfrac{r^{2}}{2}\right) &+ r^{2} \cos^{-1}\!\left(\tfrac{r}{2}\right)\\ &- \left(1 + \tfrac{r^{2}}{2}\right)\!\left(1 - \tfrac{r^{2}}{2}\right) \sqrt{\,r^{2} - \tfrac{r^{4}}{4}\,} \;=\; \tfrac{\pi}{2}. \end{align*} There is no clean closed form. Numerical solution gives r    1.1587R.\boxed{r \;\approx\; 1.1587 R.} The qualitative picture is right: because the field’s curvature pinches the lens, the tether has to be slightly longer than the radius of the field to enclose half the area. The shortfall, compared to a flat fence (which would need r=Rπ/22/π=Rr = R \sqrt{\pi/2 \cdot 2/\pi} = R for a half-disc), is the extra 15.87%15.87\%.

The computation

Encode the lens area directly from the two circles and solve A1+A2=π/2A_1 + A_2 = \pi/2 numerically.

  1. Write the lens area as a function of rr, with R=1R = 1.

  2. Bisect on rr between 00 and 22 to find the root of lens(r)π/2\text{lens}(r) - \pi/2.

  3. Report rr and verify the lens area against a Monte Carlo sample.

from math import acos, sqrt, pi
import random

def lens_area(r, R=1.0):
    d = R  # anchor on the fence
    a = (R*R*acos((d*d + R*R - r*r) / (2*d*R))
         + r*r*acos((d*d + r*r - R*R) / (2*d*r))
         - 0.5*sqrt((-d+r+R)*(d+r-R)*(d-r+R)*(d+r+R)))
    return a

lo, hi = 0.5, 1.9
for _ in range(80):
    mid = 0.5 * (lo + hi)
    if lens_area(mid) < pi / 2:
        lo = mid
    else:
        hi = mid
r_star = 0.5 * (lo + hi)
print(f"tether length r/R = {r_star:.6f}")
print(f"lens area at r* = {lens_area(r_star):.6f} (target {pi/2:.6f})")

# Monte Carlo cross-check
random.seed(0)
N = 1_000_000
inside_field = 0
inside_lens = 0
for _ in range(N):
    x = random.uniform(-1, 1)
    y = random.uniform(-1, 1)
    if x*x + y*y <= 1:
        inside_field += 1
        if (x - 1)**2 + y*y <= r_star*r_star:
            inside_lens += 1
print(f"MC lens / field = {inside_lens / inside_field:.4f} (target 0.5)")

The bisection converges to r/R=1.158728r/R = 1.158728, the lens area equals π/2\pi/2 to machine precision, and the Monte Carlo sample reports 0.50000.5000 to four decimals.