Beside the Point — a Jane Street puzzle in geometric probability
puzzle
math
python
How I solved Jane Street’s November 2024 puzzle with one symmetry argument, two circles, and a single integral.
Author
Victor S HUANG
Published
01 Dec 2024
A short writeup I owed myself. The November 2024 Jane Street puzzle asked:
Two random points, one red and one blue, are chosen uniformly and independently from the interior of a square. To ten decimal places, what is the probability that there exists a point on the side of the square closest to the blue point that is equidistant to both the blue point and the red point?
Place the square as \(S = [0,1]^2\). Call the blue point \(B\) and the red point \(R\). Let \(\ell\) be the side of \(S\) closest to \(B\).
The puzzle asks for the probability that some \(C \in \ell\) satisfies \(d(B, C) = d(R, C)\).
The set of points equidistant from \(B\) and \(R\) is the perpendicular bisector of segment \(BR\). So the condition is:
The perpendicular bisector of \(BR\) crosses the closest side \(\ell\).
Equivalently: the two endpoints of \(\ell\) lie on opposite sides of the bisector. Translating “side of the bisector” back to distance, that means one endpoint is closer to \(B\) and the other is closer to \(R\).
That is the form I’ll use.
Cutting the work down with symmetry
The square has 8-fold dihedral symmetry. By rotating and reflecting, I can assume \(B\) lives in one specific octant — the lower triangle below the line \(y = x\) with \(x < 1/2\):
\[
B = (x, y), \qquad 0 < y < x < \tfrac{1}{2}.
\]
In this octant the closest side is the bottom edge from \((0,0)\) to \((1,0)\). Its endpoints are the two corners \(P_0 = (0,0)\) and \(P_1 = (1,0)\).
\(P_0\) is closer to \(B\) than to \(R\), and\(P_1\) is closer to \(R\) than to \(B\), or
the same with \(P_0\) and \(P_1\) swapped.
“\(P_i\) is closer to \(B\) than to \(R\)” means \(R\) is outside the circle centered at \(P_i\) that passes through \(B\). Call those circles \(\mathcal{C}_0\) and \(\mathcal{C}_1\):
Figure 1: Blue point \(B\) in the lower octant. The favourable region for \(R\) is the symmetric difference of the two disks (shaded blue).
Quick Monte Carlo gut-check
Before grinding through an integral I always like to run the simulation. If the analytic answer disagrees with a million random trials, the analytic answer is wrong.
rng = np.random.default_rng(20241201)N =1_000_000B = rng.random((N, 2))R = rng.random((N, 2))# Closest side of B: 0=bottom, 1=top, 2=left, 3=right.dists = np.stack([B[:, 1], 1- B[:, 1], B[:, 0], 1- B[:, 0]], axis=1)side = np.argmin(dists, axis=1)# Reflect/rotate so that the closest side is always the bottom.# Equivalent to working in the octant — but here I just transform B and R together.Bp, Rp = B.copy(), R.copy()top = side ==1Bp[top, 1] =1- Bp[top, 1]; Rp[top, 1] =1- Rp[top, 1]left = side ==2Bp[left] = Bp[left, ::-1]; Rp[left] = Rp[left, ::-1]right = side ==3Bp[right] = Bp[right, ::-1]; Rp[right] = Rp[right, ::-1]Bp[right, 1] =1- Bp[right, 1]; Rp[right, 1] =1- Rp[right, 1]# Two-circles condition: R inside one disk and outside the other.in0 = Bp[:, 0] **2+ Bp[:, 1] **2>= Rp[:, 0] **2+ Rp[:, 1] **2in1 = (1- Bp[:, 0]) **2+ Bp[:, 1] **2>= (1- Rp[:, 0]) **2+ Rp[:, 1] **2estimate =float(np.mean(in0 ^ in1))print(f"Monte Carlo (N = {N:,}): {estimate:.6f}")
Monte Carlo (N = 1,000,000): 0.491470
That gives \(\approx 0.4914\). Now the closed form.
The integrand, geometrically
Two convenient facts about the octant \(0 < y < x < 1/2\):
Both radii satisfy \(r_i \le 1\) throughout the octant. (Worst case for \(r_1\) is \(x \to 0^+\), where \(r_1^2 \to 1 + y^2\) — but in the octant \(y < x\), so \(r_1^2 < 1 + x^2 \le 5/4\), and a quick check shows \(r_1 < 1\) whenever \(y < x\).) That means each disk’s intersection with \(S\) is a clean quarter disk: \[\operatorname{Area}(D_i \cap S) = \tfrac{\pi r_i^2}{4}.\]
The two disks meet at \(B = (x, y)\) and at its reflection \((x, -y)\) below the \(x\)-axis. Inside \(S\) we only see the upper half of the lens. Its area splits cleanly into two circular segments, one carved off each disk by the vertical chord \(u = x\):
\[
\operatorname{Area}(D_0 \cap D_1 \cap S) = s_0 + s_1,
\] where, using the sector area formula\(\tfrac12 r^2 \theta\) minus a triangle, \[
s_0 = \tfrac{1}{2}\bigl(r_0^2 \arctan(y/x) - x y\bigr), \qquad
s_1 = \tfrac{1}{2}\bigl(r_1^2 \arctan(y/(1-x)) - (1-x) y\bigr).
\]
The Monte Carlo estimate above lands within 0.001 of this — consistent with the \(O(1/\sqrt{N})\) standard error of a million-sample Bernoulli.
What made it nice
Two moves did most of the work. First, restating “perpendicular bisector hits the side” as “one corner closer to \(B\), the other closer to \(R\)” turned a metric question into a region-membership question. Second, the 8-fold symmetry collapsed the problem to a single octant, where the geometry is clean enough that every relevant area is either a quarter disk or a circular segment.
The official Jane Street solution follows the same path and arrives at the same closed form, \((1 + 2\pi - \ln 4)/12\).