Every real number can be expressed as a continued fraction [a₀; a₁, a₂, …]. The finite truncations, called convergents, are the best rational approximations to the number — no fraction with equal or smaller denominator gets closer.
p_n = a_n * p_{n-1} + p_{n-2}
q_n = a_n * q_{n-1} + q_{n-2}
|x - p_n/q_n| < 1 / (q_n * q_{n+1})
det([[p_n, p_{n-1}],[q_n, q_{n-1}]]) = (-1)^n
The golden ratio φ = [1; 1, 1, 1, …] is the hardest number to approximate by rationals — its convergents are ratios of consecutive Fibonacci numbers (1/1, 2/1, 3/2, 5/3, 8/5, …). A sunflower's spiral count is always a Fibonacci number for this reason!
A continued fraction is an expression a₀ + 1/(a₁ + 1/(a₂ + …)) where a₀ is an integer and each aₙ (n ≥ 1) is a positive integer. Every real number has such an expansion, and it is finite if and only if the number is rational.
Convergents pₙ/qₙ are the rational numbers obtained by cutting off the continued fraction after n steps. They converge alternately from above and below to the target number, and they are provably the best rational approximations — no fraction with denominator ≤ qₙ comes closer to x.
The horizontal axis shows the real number line (or a zoomed window around the target). Each convergent p/q is plotted as a vertical tick, coloured by iteration. As more terms are added the ticks alternate above/below and get exponentially closer to the red target line, illustrating the "best approximation" property visually.
Because φ satisfies φ = 1 + 1/φ, so the continued fraction literally repeats itself as [1; 1, 1, 1, …]. This means its convergents (Fibonacci ratios) converge as slowly as possible — making φ the "most irrational" number.
It is a binary tree containing every positive rational exactly once. Starting from 0/1 and 1/0 as sentinels, each new node is the mediant (a+c)/(b+d) of its two neighbours. The path to any rational encodes its continued fraction: going right means incrementing the current partial quotient, going left starts a new term.
Exponentially fast. Since qₙ grows at least as fast as Fibonacci numbers (doubling roughly every 1.44 steps), the error |x − pₙ/qₙ| < 1/qₙ² shrinks like φ^{-2n}. Large partial quotients cause even faster convergence at that step.
A large aₙ means the previous convergent p_{n-1}/q_{n-1} was already a very good approximation. The classic example is π: after [3; 7, 15, 1] the next term is 292, meaning 355/113 is an astonishingly good approximation to π (error < 3×10⁻⁷).
By Dirichlet's theorem, every irrational number has infinitely many fractions p/q satisfying |x − p/q| < 1/q². But Liouville numbers (like 0.110001000000000000000001…) are transcendental precisely because they are too well approximated. The irrationality measure quantifies how well a number can be approximated.
The solar year is approximately 365.2422 days. The continued fraction [365; 4, 7, 1, 3, …] gives convergents 365/1 (Julian), 1461/4 (still Julian 4-year cycle), 4748/13 (unused), and then the Gregorian correction: 97 leap years in 400 gives 365 + 97/400 = 146097/400 ≈ 365.2425, one step away from optimal.
The error chart plots |x − pₙ/qₙ| on a logarithmic vertical axis against convergent index n. Since each step reduces error by roughly a factor of qₙ, the points fall roughly along a straight line on the log scale, with occasional sharp drops when a large partial quotient appears.
Between consecutive convergents pₙ/qₙ and p_{n+1}/q_{n+1}, there are intermediate fractions (pₙ + k·p_{n+1})/(qₙ + k·q_{n+1}) for k = 1, …, aₙ−1 called semiconvergents. Some are best approximations of the first kind (no fraction with smaller denominator is closer) but not of the second kind. The simulation highlights them when you hover over a row.