What Is a Continued Fraction? Writing a Number as a Nest of Divisions
By the BrainSnail editorial team. How these articles are written and checked, and how to tell us when one is wrong.
Any number can be written as a whole number plus one divided by a whole number plus one divided by another, continuing as far as needed. That representation gives the best possible rational approximations and reveals things decimals conceal.
How the expansion works
To expand a number, take the whole part, subtract it, invert what remains and repeat. The whole parts recorded at each step form the expansion, and the process terminates exactly when the original number is rational, since the remainder eventually becomes zero. An irrational number produces an expansion that never terminates. Truncating the expansion at any point and working back through the divisions gives a fraction called a convergent, and those fractions approach the original number alternately from above and below, getting closer at each step. That procedure is essentially the ancient algorithm for finding the greatest common divisor of two numbers run in a different direction, which is why the expansion of a rational number terminates and why the two subjects are connected.
What the representation reveals
Properties that are invisible in a decimal expansion become obvious here:
- •Rationality, since the expansion terminates exactly when the number is rational
- •The best rational approximations, since the convergents are provably the closest fractions for their size of denominator
- •How well a number can be approximated, since a large term in the expansion means the preceding convergent is unusually good
- •The golden ratio, whose expansion is entirely ones, which makes it the number hardest to approximate by fractions
- •Square roots of whole numbers, whose expansions are eventually periodic, which is a theorem
- •The base of natural logarithms, whose expansion follows a simple regular pattern that its decimal conceals entirely
The calendar and the gears
The best-approximation property has been used practically for a long time. Calendar design requires approximating the length of the year by a whole number of days with occasional extra ones, and the successive convergents to the true figure give the schemes actually adopted, with one convergent producing a leap year every four years and a better one producing the more accurate rule used since 1582. Musical tuning faces the same problem, since the ratio between an octave and a fifth is irrational and the convergents give the number of notes per octave that work reasonably, which is where twelve comes from. Gear trains approximating an irrational ratio use convergents to choose tooth counts, and the technique was used in astronomical clocks and orreries. In each case the question is the same, namely the best fraction with a manageable denominator.
The golden ratio result
The claim that one particular number is the hardest to approximate by fractions deserves unpacking, since it is the most striking single fact about this representation. A large term in an expansion means the fraction formed by truncating just before it is unusually accurate, so a number with large terms is well approximated by simple fractions. The golden ratio has an expansion consisting entirely of ones, which are the smallest possible terms, so it never presents such an opportunity and its convergents improve as slowly as any number's can. That is what makes it the worst case, and it has physical consequences, since a system where two frequencies are in a ratio close to a simple fraction tends to lock together while one at the worst-approximable ratio resists, which appears in planetary orbits, in the arrangement of leaves on a stem and in the stability of dynamical systems generally.
Where it comes up now
The representation remains a working tool in several areas. Number theory uses it extensively, including in the theory of how well irrational numbers can be approximated, which is a substantial field with its own classification of numbers by approximability. Solving certain equations in whole numbers uses the expansion of a square root directly, which is a method going back to Indian and Greek mathematics. Computer arithmetic uses it to find the simplest fraction within a given tolerance, which arises in converting between representations and in rendering. Cryptanalysis uses it in an attack on a public key system when a particular parameter is chosen badly. And it appears in the analysis of dynamical systems, where how well a frequency ratio can be approximated determines whether an orbit is stable, which connects the arithmetic directly to physical behaviour.
The takeaway
Take the whole part, invert the remainder and repeat, and the expansion terminates exactly when the number is rational. Truncating gives convergents, which are provably the best fractions for their denominator size. The golden ratio has an expansion of all ones, making it the hardest number to approximate. Calendar leap year rules and twelve-note tuning both come from convergents.