Ford circles — Farey neighbors and tangency

What this is?

Ford circles over [0,1]. For each reduced fraction p/q we draw the circle with center (p/q, 1/(2q²)) and radius 1/(2q²). Two Ford circles are tangent exactly when |p₁q₂ − p₂q₁| = 1 (Farey neighbors). The drawing uses a single, uniform scale and clips circles to the half-plane y ≥ 0 for clean tangencies.

Answer — drawing

Reason

  1. Circle for p/q has center (p/q, 1/(2q²)) and radius r = 1/(2q²). It is tangent to y = 0 at x = p/q.
  2. Two fractions p₁/q₁ and p₂/q₂ are neighbors in a Farey sequence exactly when |p₁q₂ − p₂q₁| = 1. Their Ford circles are then tangent; otherwise the circles are disjoint.
  3. Sorting all reduced fractions with denominator ≤ N gives the Farey sequence of order N, so consecutive entries are neighbors and their circles kiss.

Check

Automatic verification: