If someone asks you to write down a good approximation to , you probably reach for or or . The choice between them feels arbitrary. The truncated decimal is convenient because we use base 10. The fractions are convenient because they’re cute. There seems to be no principled way to say which approximation is “best.”
It turns out there is. Hidden inside every real number is a sequence of canonically best rational approximations, and the rule that produces them is one of the cleanest constructions in number theory. The mechanism is called continued fractions, and once you know about it, you start seeing it everywhere — in the design of the Gregorian calendar, in the rotor frequencies of synthesisers, in the irrationality proofs of and , and in the most efficient way a computer can store certain numbers.
This article explains what continued fractions are, why their convergents are special, and what they reveal about familiar irrationals.
The recipe
Take any real number, say Write it as an integer plus a fractional part:
Now invert the fractional part. Repeat: that’s an integer (7) plus a small fractional part. Invert again. Continue.
Working through the numbers:
The sequence of integers extracted at each step — — is the continued fraction expansion of . It’s compact notation to write this as .
Truncate the expansion at any point and convert it back to an ordinary fraction:
| Truncation | Fraction | Decimal | Error |
|---|---|---|---|
| to 9 digits |
Each truncation is called a convergent. They alternately overshoot and undershoot the true value, getting closer with each step.
Now here is the magic. Each convergent is the best rational approximation to for any denominator up to the next convergent’s denominator. No fraction with a denominator less than 33102 approximates better than . This is a theorem, not a coincidence. The convergents of a continued fraction are the unambiguously optimal rational approximations.
That’s why is so famous: it’s accurate to 6 decimal places with a denominator of just 113. The next convergent is twenty times more accurate but requires a six-digit denominator.
Why this works
The reason continued fractions produce optimal approximations is a theorem proved by Lagrange in 1770: a fraction in lowest terms is a convergent of the continued fraction of if and only if
In words: convergents are precisely the fractions that approximate better than , where is their denominator. No fraction with a smaller denominator can do better. This is the cleanest statement of Diophantine approximation theory in its classical form.
The continued fraction algorithm, applied to any irrational, produces an infinite sequence of these optimal approximations — and the sequence is canonical. There is exactly one such sequence per number. Decimals depend on base 10; continued fractions don’t.
Special continued fractions
Some numbers have continued fractions with striking patterns.
The golden ratio has the simplest possible continued fraction:
All the integers are 1. The convergents — — are ratios of consecutive Fibonacci numbers. This is not a coincidence: satisfies , which is exactly the recursion behind Fibonacci.
Because the continued fraction of has all 1s — the smallest possible terms — its convergents converge to it more slowly than for any other irrational. In a precise mathematical sense, is the most irrational of all real numbers — the hardest to approximate by rationals. This is why nature uses for arrangements that need to be maximally non-aligned: sunflower seed spirals, leaf phyllotaxis. Any rational rotation angle would eventually overlap; only stays maximally spread out.
The number has the eventually periodic continued fraction . Its convergents — — form a famous sequence. Each numerator and denominator is generated by . The fraction is the rational approximation hidden in old engineering rules of thumb for the diagonal of a square.
Euler’s number has a continued fraction with an unusual but predictable pattern:
The pattern repeats with increasing — Euler proved this in 1737, and the proof is a small masterpiece. The fact that the pattern is predictable but non-periodic is one of the clearest ways to see that is irrational. (A periodic continued fraction would mean satisfies a quadratic equation with integer coefficients, which it doesn’t.)
The continued fraction of , by contrast, has no known pattern. Its terms appear random: . The occasional large term (the 292, the 14) produces the spectacularly good convergent . There is no formula generating these terms; you have to compute them.
A theorem about quadratic irrationals
Here’s a theorem that connects continued fractions to algebra in a clean way.
Theorem (Lagrange, 1770): A real number has an eventually periodic continued fraction if and only if it is a quadratic irrational — a root of an integer polynomial of degree 2.
So , , , , and all square roots of non-square integers have eventually periodic continued fractions. In fact, the period of encodes deep number-theoretic structure: lengths of periods are connected to the class number of , a fundamental invariant in algebraic number theory.
This is why continued fractions appear in algorithms for computing class numbers, solving Pell’s equation , and proving irrationality. Pell’s equation specifically: its solutions are exactly the convergents to at certain points in the periodic cycle.
Continued fractions in the real world
The most familiar place continued fractions show up is in the design of calendars.
The Earth’s year is approximately days long. To make a calendar that doesn’t drift, you need rational approximations:
The convergents are , , , , , etc.
- The first convergent ( days/year exactly) is the simplest calendar — drifts about 0.24 days per year.
- The second (, i.e. one leap year per 4) is the Julian calendar — accurate enough that it took 1500 years to notice the drift.
- The fifth convergent () is the basis of the Gregorian reform: leap years every 4 years, except every 100, except every 400. Mathematically, this is approximating by , very close to .
The Gregorian calendar will lose one day every 3300 years or so. The next convergent would do better, but the approximation is already finer than the long-term variability of Earth’s rotation, so further refinement is meaningless.
Similar logic underlies:
- Gear ratios in mechanical clocks (which integer ratio of teeth most closely approximates a target rotation rate?)
- Frequency synthesisers in radio and audio (rational frequency multiplications)
- Computer arithmetic for representing irrationals with limited precision
- Music tuning (the equal-tempered scale’s has a continued fraction that explains why 12-tone equal temperament is special)
What continued fractions teach
For a beginner, continued fractions are striking because they reveal that numbers have more structure than the decimal expansion shows. The decimal doesn’t tell you that the next-to-best fraction approximating is . The decimal of doesn’t tell you it’s the most-irrational number that exists. The decimal of hides a beautiful pattern.
For a working mathematician, continued fractions are a glimpse into algebraic and Diophantine structure that lives below the surface of the real numbers. The behaviour of a number’s continued fraction tells you about its algebraic properties (rational, quadratic, transcendental), about its approximability, and about its relationship to lattices and quadratic forms.
The remarkable thing is that this entire infrastructure has been there since Euclid — the algorithm to extract a continued fraction is essentially the Euclidean algorithm applied to real numbers — and most of it can be derived with high-school algebra. The depth comes from how it connects to problems no one would expect to be related: irrationality proofs, Pell’s equation, Stern-Brocot trees, the Markov spectrum, the dynamics of the Gauss map.
You can spend a career studying continued fractions. Most people stop at . Both responses are appropriate. The mathematics is rich enough to support either.
Frequently asked
Why are continued fractions better than decimals?
Decimals are arbitrary — they reflect base 10. Continued fractions are basis-free: they are the canonical sequence of best rational approximations to any real number. The convergents are guaranteed to be better than any other fractions with smaller denominators, a property no decimal expansion can claim.
Is the continued fraction of every irrational number infinite?
Yes. A finite continued fraction always represents a rational number. The continued fraction of an irrational has infinitely many terms. The pattern of those terms encodes deep arithmetic information — for example, quadratic irrationals have eventually periodic continued fractions, while transcendentals usually do not.