← All Labs
INTERACTIVE APPLET · NUMBER THEORY & APPROXIMATION

Continued Fractions & the Most Irrational Number

Every real number has a unique fingerprint: peel off its whole part, flip the leftover, and repeat. The digits you collect — [a₀; a₁, a₂, …] — are its continued fraction, and they tell you exactly how well the number can be chased by simple fractions. Big coefficients mean a lucky fraction is hiding nearby (π ≈ 22/7 because a₂ = 15 is large). The number whose coefficients are all 1s — the golden ratio φ — has no lucky shortcuts anywhere, which is what makes it the most irrational number of all. Type a number, step the algorithm, and watch a rectangle tile itself into squares.

x = a₀ + 1/(a₁ + 1/(a₂ + …))

A rectangle's squares are a number's continued fraction

Type any real number or a p/q fraction · drag the slider to reveal more terms
Canvas · exact convergent recurrence

DRIVE IT

square block (one coefficient aₖ) golden spiral arc leftover rectangle

IRRATIONALITY METER

HARDNESS TO APPROXIMATE
smaller coefficients ⇒ harder

THE NUMBER x

REVEAL TERMS

SHOW

CONVERGENTS pₙ/qₙ

WALKTHROUGH

  1. Start with φ = (1+√5)/2. The continued fraction is [1; 1, 1, 1, …] — every coefficient is the smallest it could possibly be. Watch the rectangle cut off exactly one square at each stage, forever, spiralling inward as the golden rectangle.
  2. Switch to π. The expansion is [3; 7, 15, 1, 292, …]. Notice the big 15 right after 7 — that is why 22/7 is such a famously good approximation, and the giant 292 is why 355/113 nails π to six decimals.
  3. Drag reveal terms. Each new coefficient adds a fresh block of squares and a new row in the convergents table — watch the error column shrink by roughly a factor of qₙ² each step.
  4. Type a fraction like 22/7. A rational number terminates: the squares tile the rectangle perfectly with no leftover, because the algorithm is Euclid's GCD in disguise.
  5. Compare the irrationality meter across φ, √2, e and π. φ sits at the bottom (all 1s) — no number is harder to pin down with a simple fraction.
AHA
A continued fraction is Euclid's algorithm run on a length instead of a whole number — tiling a rectangle with the biggest squares that fit, over and over. Each coefficient aₖ is how many squares of that size you can take, and a large aₖ means the leftover is tiny, so the fraction you have so far is already an excellent approximation (that is the 15 hiding behind π's 22/7). The golden ratio φ = [1; 1, 1, …] is the one number where every coefficient is 1 — the leftover never collapses, no shortcut ever appears — so φ is provably the slowest number to approximate with rationals. "Most irrational" isn't poetry: it's the arithmetic fact that φ's convergents converge as slowly as mathematically possible.

RESEARCH NOTE — how good is pₙ/qₙ?

The convergents obey the recurrence \(p_n = a_n p_{n-1} + p_{n-2}\), \(q_n = a_n q_{n-1} + q_{n-2}\), and the approximation error is squeezed between \(\tfrac{1}{q_n(q_{n+1}+q_n)} < \left|x-\tfrac{p_n}{q_n}\right| < \tfrac{1}{q_n q_{n+1}} = \tfrac{1}{q_n^2 a_{n+1}+\dots}\).

So the error falls like \(1/(a_{n+1} q_n^2)\): a large next coefficient makes the current convergent superb. All-1s (φ) is the worst case — the denominators grow like Fibonacci numbers \(q_n=F_{n+1}\), giving \(|x-p_n/q_n|\to 1/(\sqrt5\,q_n^2)\), Hurwitz's theorem's sharp constant. Read more: Khinchin, Continued Fractions; Hardy & Wright, ch. X–XI; the Stern–Brocot tree for where the convergents sit among all fractions.