A clock can only turn at ratios of whole numbers of teeth. To make a moon dial or a planetarium, a clockmaker needs fractions close to awkward numbers with tops and bottoms that factor into wheels he can cut. A Paris clockmaker found the way down a tree of fractions.
Start between the whole numbers either side. Each step adds tops and bottoms, a/b and c/d giving (a + c)/(b + d), which always lies between them; keep the half that holds the number (L or R). Each row is zoomed to its own interval. A filled dot is closer than every fraction before it.
The tree. Starting from 0/1 and 1/0 and inserting mediants forever produces every positive fraction exactly once, in lowest terms. Moritz Stern described it in 1858 and Achille Brocot, a clockmaker, in 1861, for different reasons: Stern for number theory, Brocot for cutting wheels.
Best approximations. Every fraction that comes closer to x than any fraction with a smaller bottom lies on the path down to x. The runs of L and R are the terms of the continued fraction: π is [3; 7, 15, 1, 292, ...], and the long run of 292 is why 355/113 is so good.
Hard numbers. The golden ratio is all ones: its path zigzags L, R, L, R and every fraction is a ratio of Fibonacci numbers, closing in as slowly as any number can.
The ratio is turns of the driver for one turn of the last wheel. With two pairs, a drives b, c turns with b on the same axle and drives d, and the ratio is (b × d) / (a × c). The page tries every pair of tooth counts and keeps the closest.
The moon dial. A moon-phase clock advances a disc of 59 teeth by one tooth a day and paints two moons on it, so a lunation takes 59/2 = 29.5 days. The real month is 29.530589 days, and the dial is a day wrong after about two and a half years. Better fractions need more wheels.
Primes get in the way. The closest fractions often have a large prime on top or bottom, and no wheel can have 4,723 teeth. Brocot's method moves along the tree to a nearby fraction whose top and bottom split into factors small enough to cut, and checks how much accuracy that costs.
Antikythera. The Greek mechanism found in a wreck off Antikythera, from the second or first century BC, used the Metonic cycle, 235 months in 19 years, which the tree finds for the months in a year, and a wheel of 223 teeth for the eclipse cycle: gear ratios as astronomy.