Books · The Fiddler: Solutions
Chapter 52
Can You Weave the Web?
A spider picks two points uniformly at random inside a unit square and runs a straight strand of silk through them, extending it to the square’s sides. Which point of the square is most likely to lie on such a strand?
The Fiddler, Zach Wissner-Gross, May 30, 2025(original post)
Solution
Fix a target point . The pairs of points whose connecting line passes through are parametrised by the line’s angle and the two points’ positions along it; the Jacobian for two points on a line is their separation, and integrating it along the chord of length gives a density Longer chords in every direction mean a larger density, and the centre maximises every chord, so the most likely point is the
The computation
Weave the actual web: draw millions of random point-pairs, and for a candidate target measure how often the line through a pair passes within a hair of it. The centre is hit most.
import numpy as np
rng = np.random.default_rng(0)
P1 = rng.random((20_000_000, 2)); P2 = rng.random((20_000_000, 2))
d = P2 - P1; den = np.hypot(d[:, 0], d[:, 1])
def hit_rate(z, eps=0.003): # strands passing within eps of z
num = np.abs(d[:, 0]*(P1[:, 1] - z[1]) - d[:, 1]*(P1[:, 0] - z[0]))
return (num / den < eps).mean()
print(hit_rate((0.5, 0.5)) > hit_rate((0.3, 0.4))) # True: centre is largest
Extra Credit
What is the ratio of the largest density to the smallest, over all points of the square?
Solution
The density is largest at the centre and smallest at the midpoints of the edges (a corner actually fares better, helped by the long diagonal chord). Taking the ratio of strand hit-rates there, (The source’s value is paywalled; this is my own.)
The computation
The same hit-rate from the main section, taken at the centre and at an edge midpoint.
print(round(hit_rate((0.5, 0.5)) / hit_rate((0.5, 0.0)), 3)) # ~2.58