Key idea of this section
x = [a₀; a₁, a₂, …], pn = an pn−1 + pn−2, qn = an qn−1 + qn−2, pn qn−1 − pn−1 qn = (−1)n−1, x − pn/qn = (−1)n / (qn(xn+1 qn + qn−1)).
The continued fraction algorithm
For a real number x, set x₀ = x and define recursively:
an = ⌊xn⌋, xn+1 = 1/(xn − an) (if xn ≠ an).
The integers an are the partial quotients and the xn the complete quotients. Then a₀ ∈ ℤ, an ≥ 1 for n ≥ 1, and
x = a₀ + 1/(a₁ + 1/(a₂ + ⋯)) =: [a₀; a₁, a₂, …].
If x = h/k is rational, the algorithm is precisely the Euclidean algorithm applied to h and k: the partial quotients are the successive quotients. It therefore stops, and every rational number has a finite continued fraction. For example, for 67/29:
67 = 2·29 + 9, 29 = 3·9 + 2, 9 = 4·2 + 1, 2 = 2·1,
so 67/29 = [2; 3, 4, 2]. A finite expansion whose last partial quotient exceeds 1 can be rewritten using [… , ar] = [… , ar − 1, 1]; apart from this ambiguity the expansion of a rational is unique. Conversely the algorithm never stops when x is irrational, since every complete quotient is then irrational.
Convergents and the matrix formalism
Define p₋₂ = 0, p₋₁ = 1, q₋₂ = 1, q₋₁ = 0, and:
pn = an pn−1 + pn−2, qn = an qn−1 + qn−2 (n ≥ 0).
Proposition 7.1. For every n ≥ 0,
( a₀ 1 ; 1 0 )( a₁ 1 ; 1 0 ) ⋯ ( an 1 ; 1 0 ) = ( pn pn−1 ; qn qn−1 ),
and for any real t > 0, [a₀; a₁, …, an, t] = (t pn + pn−1)/(t qn + qn−1). In particular [a₀; a₁, …, an] = pn/qn.
Proof. The matrix identity follows by induction, since multiplying (pn−1 pn−2; qn−1 qn−2) on the right by (an 1; 1 0) produces exactly the recurrences. The second statement is also proved by induction on n: [a₀; a₁, …, an, t] = [a₀; a₁, …, an−1, an + 1/t], and by the inductive hypothesis this equals ((an + 1/t)pn−1 + pn−2)/((an + 1/t)qn−1 + qn−2); multiplying through by t gives (t pn + pn−1)/(t qn + qn−1). ∎
Taking determinants in the matrix identity, each factor having determinant −1, gives the fundamental identity
pn qn−1 − pn−1 qn = (−1)n−1.
Consequences: gcd(pn, qn) = 1, so the convergents pn/qn are automatically in lowest terms, and consecutive convergents are Farey neighbours. Also pn qn−2 − pn−2 qn = (−1)n an, which shows that the even convergents increase and the odd convergents decrease.
The error formula
Applying Proposition 7.1 with t = xn+1 gives x = (xn+1pn + pn−1)/(xn+1qn + qn−1), and subtracting pn/qn yields
x − pn/qn = (−1)n / ( qn (xn+1 qn + qn−1) ).
Since an+1 < xn+1 < an+1 + 1 for irrational x, the denominator lies strictly between qn qn+1 and qn(qn+1 + qn). Hence:
Theorem 7.2. For irrational x the convergents alternate around x, and
1/(qn(qn + qn+1)) < |x − pn/qn| < 1/(qn qn+1) ≤ 1/qn².
In particular pn/qn → x, so every infinite sequence a₀ ∈ ℤ, a₁, a₂, … ≥ 1 defines a real number, and the correspondence between irrational numbers and such sequences is a bijection.
Since qn ≥ qn−1 + qn−2, the denominators grow at least as fast as the Fibonacci numbers: qn ≥ Fn+1. Hence the convergence is at least geometric, with ratio governed by the golden ratio.
Classical expansions
The simplest infinite continued fraction is the golden ratio, φ = (1 + √5)/2 = [1; 1, 1, 1, …], because φ = 1 + 1/φ. Its convergents are ratios of consecutive Fibonacci numbers, 1, 2, 3/2, 5/3, 8/5, 13/8, … , and since all partial quotients are as small as possible, φ is in a precise sense the irrational number hardest to approximate by rationals (Lesson 8). Similarly √2 = [1; 2, 2, 2, …], since √2 + 1 = 2 + 1/(√2 + 1), with convergents 1, 3/2, 7/5, 17/12, 41/29, 99/70, …. Euler found the regular pattern
e = [2; 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, …],
whose convergents are 2, 3, 8/3, 11/4, 19/7, 87/32, 106/39, 193/71, …. No pattern is known for π:
π = [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, …],
with convergents 3, 22/7, 333/106, 355/113, 103993/33102, …. The large partial quotient 292 explains why 355/113, found by Zu Chongzhi in the fifth century, is so good: by Theorem 7.2 its error is less than 1/(113·33102) ≈ 2.67·10⁻⁷, and in fact π − 355/113 ≈ −2.668·10⁻⁷.
Metric theory
For almost every real number x with respect to Lebesgue measure, the partial quotients have the Gauss–Kuzmin distribution: the asymptotic frequency of the value k is log₂(1 + 1/(k(k + 2))). Thus about 41.5% of the partial quotients are 1. Khinchin proved that the geometric mean (a₁a₂⋯an)1/n tends almost surely to a universal constant K₀ ≈ 2.6854, and Lévy proved that qn1/n tends almost surely to eπ²/(12 ln 2) ≈ 3.2758. It is not known whether π satisfies Khinchin's law; e does not, because its partial quotients grow.
Exercise
- (a)Compute the continued fraction expansion of 157/68.
- (b)List its convergents and verify the determinant identity for the last two.
Show solution
Answers: (a) 157 = 2·68 + 21, 68 = 3·21 + 5, 21 = 4·5 + 1, 5 = 5·1, so 157/68 = [2; 3, 4, 5]. (b) The numerators are 2, 3·2 + 1 = 7, 4·7 + 2 = 30, 5·30 + 7 = 157, and the denominators 1, 3, 13, 5·13 + 3 = 68, so the convergents are 2, 7/3, 30/13, 157/68. Check: 157·13 − 30·68 = 2041 − 2040 = 1 = (−1)3−1.