Skip to content
Vamshi Jandhyala

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 zz. The pairs of points whose connecting line passes through zz are parametrised by the line’s angle θ\theta 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 (θ,z)\ell(\theta,z) gives a density f(z)  0π(θ,z)3dθ.f(z)\ \propto\ \int_0^{\pi}\ell(\theta,z)^3\,d\theta . Longer chords in every direction mean a larger density, and the centre maximises every chord, so the most likely point is the centre of the square.\boxed{\text{centre of the square}}.

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 pmax/pminp_{\max}/p_{\min} 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, pmaxpmin=f(centre)f(edge midpoint)2.58.\frac{p_{\max}}{p_{\min}}=\frac{f(\text{centre})}{f(\text{edge midpoint})}\approx\boxed{2.58}. (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