Key idea of this section
Convergents are best approximations; |x − p/q| < 1/(2q²) forces p/q to be a convergent; the expansion of x is eventually periodic iff x is a quadratic irrational.
Best approximations
Theorem 8.1 (Lagrange). Let x be irrational and n ≥ 0. If p, q are integers with 0 < q < qn+1, then |qx − p| ≥ |qn x − pn|, with equality only for (p, q) = (pn, qn).
Proof. Because pn qn+1 − pn+1 qn = ±1, there are integers u, v with p = u pn + v pn+1 and q = u qn + v qn+1. If v = 0, then (p, q) = u(pn, qn) with u ≥ 1 and the claim is clear. If u = 0, then q = v qn+1 ≥ qn+1, which is excluded. Otherwise u and v have opposite signs: if v > 0 then u qn = q − v qn+1 < 0, and if v < 0 then u qn > 0. By Theorem 7.2 the numbers qn x − pn and qn+1x − pn+1 also have opposite signs. Hence u(qn x − pn) and v(qn+1x − pn+1) have the same sign, and
|qx − p| = |u|·|qn x − pn| + |v|·|qn+1 x − pn+1| > |qn x − pn|. ∎
Corollary 8.2. If |x − p/q| < |x − pn/qn| then q > qn. Indeed, if q ≤ qn then q < qn+1, so |x − p/q| = |qx − p|/q ≥ |qn x − pn|/qn = |x − pn/qn|.
So no fraction with denominator at most qn is closer to x than pn/qn. Not every best approximation is a convergent: the best approximations in the sense of Corollary 8.2 also include certain intermediate fractions (pn−1 + k pn)/(qn−1 + k qn). For π, the next fraction closer than 355/113 is the intermediate fraction 52163/16604, and no fraction with denominator between 114 and 16603 does better than 355/113.
Legendre's criterion
Theorem 8.3 (Legendre). If x is irrational and |x − p/q| < 1/(2q²) with q ≥ 1, then p/q is a convergent of x.
Proof. Choose n with qn ≤ q < qn+1. By Theorem 8.1, |qn x − pn| ≤ |qx − p| < 1/(2q), so |x − pn/qn| < 1/(2q qn). If p/q ≠ pn/qn, then
1/(q qn) ≤ |p/q − pn/qn| ≤ |x − p/q| + |x − pn/qn| < 1/(2q²) + 1/(2q qn),
so 1/(2q qn) < 1/(2q²), i.e. q < qn, a contradiction. ∎
Conversely, Vahlen showed that of any two consecutive convergents at least one satisfies |x − p/q| < 1/(2q²), which recovers Theorem 6.2. Borel (1903) proved that of any three consecutive convergents at least one satisfies |x − p/q| < 1/(√5 q²); in particular (Hurwitz, 1891) every irrational x has infinitely many approximations of this quality.
Proposition 8.4. The constant √5 is optimal: for c > √5 the golden ratio φ has only finitely many approximations with |φ − p/q| < 1/(c q²).
Proof. Since c > 2, by Legendre's theorem such p/q must be convergents, i.e. Fn+2/Fn+1. Let ψ = (1 − √5)/2 = −1/φ. Binet's formula gives Fk+1 − φFk = ψk, so q(qφ − p) = −Fn+1ψn+1 = −(φn+1 − ψn+1)ψn+1/√5 = (−(−1)n+1 + ψ2n+2)/√5. Thus q²|φ − p/q| → 1/√5 > 1/c, and only finitely many n can satisfy the inequality. ∎
If φ and the numbers equivalent to it under SL₂(ℤ) (those whose expansions end in all 1s) are excluded, the constant improves to √8; the next values are √221/5, √1517/13, …, accumulating at 3. This is the beginning of the Lagrange and Markov spectra, governed by the solutions of the Markov equation x² + y² + z² = 3xyz.
Quadratic irrationals
A real number is a quadratic irrational if it is irrational and satisfies a quadratic equation with integer coefficients.
Theorem 8.5 (Euler, Lagrange). The continued fraction of x is eventually periodic if and only if x is a quadratic irrational.
Proof of the easy direction (Euler). If x = [a₀; …, as−1, y] with y = [b₀; …, bt−1, y] purely periodic, then by Proposition 7.1, y = (yP + P′)/(yQ + Q′) for integers P, P′, Q, Q′ with Q > 0, so Qy² + (Q′ − P)y − P′ = 0 is a quadratic equation; y is irrational because its expansion is infinite. Then x = (yp + p′)/(yq + q′) is a Möbius image of y with integer coefficients, hence lies in ℚ(y) ∖ ℚ and is a quadratic irrational. ∎
Proof of the hard direction (Lagrange). Let ax² + bx + c = 0 with a, b, c ∈ ℤ, a ≠ 0 and discriminant Δ = b² − 4ac > 0, not a square. Substituting x = (xn pn−1 + pn−2)/(xn qn−1 + qn−2) shows that the complete quotient xn satisfies An xn² + Bn xn + Cn = 0, where
An = a pn−1² + b pn−1 qn−1 + c qn−1², Cn = An−1,
and, because the substitution matrix has determinant ±1, Bn² − 4An Cn = Δ. Writing f(t) = at² + bt + c = a(t − x)(t − x′), we have An = qn−1² f(pn−1/qn−1) = a qn−1²(pn−1/qn−1 − x)(pn−1/qn−1 − x′). The first factor is less than 1/qn−1² in absolute value and the second is bounded by |x − x′| + 1, so |An| < |a|(|x − x′| + 1) is bounded independently of n; the same holds for Cn = An−1, and then Bn² = Δ + 4AnCn is bounded too. Only finitely many integer triples (An, Bn, Cn) therefore occur, each with at most two roots, so the complete quotients xn take only finitely many values. Hence xi = xj for some i < j, and the expansion is periodic from position i on. ∎
Galois added a refinement: the expansion is purely periodic exactly when x > 1 and its conjugate x′ satisfies −1 < x′ < 0. From this one derives that for a non-square integer N ≥ 2,
√N = [a₀; a₁, a₂, …, aℓ−1, 2a₀, a₁, a₂, …], with ak = aℓ−k for 1 ≤ k ≤ ℓ − 1,
where the block a₁, …, aℓ−1, 2a₀ of length ℓ repeats forever and its first ℓ − 1 entries form a palindrome. For example √7 = [2; 1, 1, 1, 4, …], √13 = [3; 1, 1, 1, 1, 6, …], √19 = [4; 2, 1, 3, 1, 2, 8, …] and √61 = [7; 1, 4, 3, 1, 2, 2, 1, 3, 4, 1, 14, …], with periods 4, 5, 6 and 11.
Pell's equation
Theorem 8.6. Let N ≥ 2 be a non-square, let ℓ be the period of √N, and let pk/qk be its convergents. Then
pℓ−1² − N qℓ−1² = (−1)ℓ.
Every positive solution of x² − Ny² = ±1 is a convergent (x, y) = (pk, qk); the smallest positive solution of x² − Ny² = 1 is (pℓ−1, qℓ−1) if ℓ is even and (p2ℓ−1, q2ℓ−1) if ℓ is odd.
Proof of the identity. The complete quotient after one period is xℓ = a₀ + √N, so by Proposition 7.1
√N = ((a₀ + √N) pℓ−1 + pℓ−2) / ((a₀ + √N) qℓ−1 + qℓ−2).
Clearing the denominator and comparing rational and irrational parts (√N is irrational) gives N qℓ−1 = a₀ pℓ−1 + pℓ−2 and pℓ−1 = a₀ qℓ−1 + qℓ−2. Hence
pℓ−1² − N qℓ−1² = pℓ−1(a₀qℓ−1 + qℓ−2) − qℓ−1(a₀pℓ−1 + pℓ−2) = pℓ−1qℓ−2 − pℓ−2qℓ−1 = (−1)ℓ.
Proof that solutions are convergents. If x² − Ny² = ±1 with x, y ≥ 1, then x ≥ y (because x² ≥ Ny² − 1 ≥ y²), so x + y√N > 2y and
|√N − x/y| = |x² − Ny²| / (y(x + y√N)) < 1/(2y²);
by Legendre's theorem x/y is a convergent. The description of the smallest solution follows from a finer analysis of the values pk² − Nqk², which equal (−1)k+1 times the denominators of the complete quotients. ∎
The solutions of x² − Ny² = 1 are the units of norm 1 in ℤ[√N], and they form the group {±εk : k ∈ ℤ}, where ε = x₁ + y₁√N is the fundamental solution. (If ε > 1 is the least unit of norm 1 and η > 1 is any other, choose k with εk ≤ η < εk+1; then η ε−k is a unit of norm 1 in [1, ε), so equals 1.) For example:
√7: ℓ = 4, convergents 2, 3, 5/2, 8/3, 8² − 7·3² = 1 √13: ℓ = 5, p₄/q₄ = 18/5, 18² − 13·5² = −1, (18 + 5√13)² = 649 + 180√13 √61: ℓ = 11, 29718² − 61·3805² = −1, fundamental solution (1766319049, 226153980)
The last example was posed by Fermat as a challenge in 1657, but had been solved five centuries earlier by Bhāskara II using the cyclic (chakravala) method that goes back to Brahmagupta. The size of the fundamental solution can be enormous: its number of digits can be of the order of √N, which is why Pell's equation is a benchmark problem in computational number theory, where subexponential and quantum algorithms (Hallgren, 2002) compute the regulator log ε.
Exercise
- (a)Find the continued fraction of √11 and the fundamental solution of x² − 11y² = 1.
- (b)Using √19 = [4; 2, 1, 3, 1, 2, 8, …], find the fundamental solution of x² − 19y² = 1.
Show solution
Answers: (a) √11 = [3; 3, 6, …] with period 2; the convergents begin 3, 10/3, and 10² − 11·3² = 100 − 99 = 1, so (10, 3) is the fundamental solution. (b) The period is ℓ = 6, so we need p₅/q₅. Numerators: 4, 9, 13, 48, 61, 170; denominators: 1, 2, 3, 11, 14, 39. Hence (170, 39), and 170² − 19·39² = 28900 − 28899 = 1.