Continued Fractions and Diophantine Approximation

⚡ Key Takeaways

Continued fractions express real numbers as nested fractions a0+1a1+1a2+⋯a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cdots}}, and their truncations (convergents) are the provably best rational approximations to a real number. Key result: the convergents pn/qnp_n/q_n satisfy ∣x−pn/qn∣<1/qnqn+1≤1/qn2|x - p_n/q_n| < 1/q_n q_{n+1} \le 1/q_n^2, and any fraction approximating xx better than 1/2q21/2q^2 must be a convergent. Applies to: Diophantine approximation, transcendence theory, dynamical systems, cryptography (Wiener attack), and Pell's equation. Who/when: Euler, Lagrange (18th c.), Gauss, Hurwitz, Khinchin, Roth (20th c.).

💡 The Core Insight

A real number is "complicated" to approximate exactly when its continued fraction has large partial quotients, and "simple" (badly approximable) when they stay bounded. The Euclidean algorithm run on the pair (x,1)(x, 1) generates the partial quotients; its remainders generate the convergents. Truncating the expansion gives rationals that hug xx more tightly than any rational of comparable or smaller denominator — the convergents are the unique best approximations of the second kind. All of classical Diophantine approximation (Dirichlet, Hurwitz, Liouville, Roth) is a quantitative study of the growth of the denominators qnq_n relative to the size of the error.

Formal Statement

DefinitionSimple Continued Fraction and the Algorithm

For x∈Rx \in \mathbb{R}, define the continued fraction algorithm by x0=xx_0 = x and, while xn∉Zx_n \notin \mathbb{Z},

1
an=⌊xn⌋,xn+1=1xn−an.\quad a_n = \lfloor x_n \rfloor, \qquad x_{n+1} = \frac{1}{x_n - a_n}.

Derivation hint: split each xnx_n into its integer part ana_n and fractional part {xn}∈[0,1)\{x_n\} \in [0,1), then invert the fractional part to expose the next integer. The resulting sequence yields

2
x=a0+1a1+1a2+1a3+⋯=:[a0;a1,a2,a3,… ].\quad x = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cfrac{1}{a_3 + \cdots}}} =: [a_0; a_1, a_2, a_3, \dots].

Derivation hint: unwind [1] recursively: x=a0+1/x1x = a_0 + 1/x_1, x1=a1+1/x2x_1 = a_1 + 1/x_2, etc. The expansion terminates iff x∈Qx \in \mathbb{Q}. For irrational xx it is infinite and unique.

DefinitionConvergents and Recurrences

The nn-th convergent is the rational pn/qn=[a0;a1,…,an]p_n/q_n = [a_0; a_1, \dots, a_n], computed by the fundamental recurrence:

3
pn=anpn−1+pn−2,qn=anqn−1+qn−2,\quad p_n = a_n p_{n-1} + p_{n-2}, \qquad q_n = a_n q_{n-1} + q_{n-2},

with initial conditions p−1=1, p−2=0, q−1=0, q−2=1p_{-1}=1,\ p_{-2}=0,\ q_{-1}=0,\ q_{-2}=1. Derivation hint: matrix form — the product ∏k=0n(ak110)\prod_{k=0}^n \begin{pmatrix} a_k & 1 \\ 1 & 0 \end{pmatrix} has columns (pn,qn)(p_n, q_n) and (pn−1,qn−1)(p_{n-1}, q_{n-1}); induction on the last factor gives [3]. The convergents satisfy the determinant identity

4
pnqn−1−pn−1qn=(−1)n−1,\quad p_n q_{n-1} - p_{n-1} q_n = (-1)^{n-1},

Derivation hint: the matrix above has determinant ∏(−1)=(−1)n+1\prod (-1) = (-1)^{n+1}; equate this to pnqn−1−pn−1qnp_n q_{n-1} - p_{n-1}q_n. and consequently

5
pnqn−pn−1qn−1=(−1)n−1qnqn−1.\quad \frac{p_n}{q_n} - \frac{p_{n-1}}{q_{n-1}} = \frac{(-1)^{n-1}}{q_n q_{n-1}}.

Derivation hint: divide [4] by qnqn−1q_n q_{n-1}.

TheoremApproximation Quality of Convergents

For irrational x=[a0;a1,a2,… ]x = [a_0; a_1, a_2, \dots] with convergents pn/qnp_n/q_n,

6
1qn(qn+1+qn)<∣x−pnqn∣<1qnqn+1≤1qn2.\quad \frac{1}{q_n(q_{n+1}+q_n)} < \left| x - \frac{p_n}{q_n} \right| < \frac{1}{q_n q_{n+1}} \le \frac{1}{q_n^2}.

Derivation hint: write x=[a0;…,an,xn+1]x = [a_0;\dots,a_n,x_{n+1}] where xn+1>an+1≥1x_{n+1} > a_{n+1}\ge 1; then x=xn+1pn+pn−1xn+1qn+qn−1x = \frac{x_{n+1}p_n + p_{n-1}}{x_{n+1}q_n + q_{n-1}}, subtract pn/qnp_n/q_n, use [4], and bound xn+1x_{n+1}. Moreover the convergents straddle xx: even-indexed ones increase to xx from below, odd-indexed ones decrease to xx from above.

TheoremBest Approximation Property

If p/qp/q (in lowest terms, q≥1q \ge 1) satisfies ∣qx−p∣<∣qnx−pn∣|qx - p| < |q_n x - p_n| for some nn, then q>qnq > q_n. Equivalently, the convergents are exactly the best rational approximations of the second kind: no fraction with denominator ≤qn\le q_n approximates xx better in the sense of minimizing ∣qx−p∣|qx - p|. In particular, if

7
∣x−pq∣<12q2,\quad \left| x - \frac{p}{q} \right| < \frac{1}{2q^2},

then p/qp/q is a convergent of xx. Derivation hint: suppose p/qp/q satisfies [7] but is not a convergent; locate nn with qn≤q<qn+1q_n \le q < q_{n+1}, express (p,q)(p,q) in the basis {(pn,qn),(pn−1,qn−1)}\{(p_n,q_n),(p_{n-1},q_{n-1})\} via [4], and derive a contradiction on sizes.

TheoremHurwitz's Theorem — Optimal Constant

For every irrational xx, infinitely many rationals p/qp/q satisfy

8
∣x−pq∣<15 q2.\quad \left| x - \frac{p}{q} \right| < \frac{1}{\sqrt{5}\, q^2}.

The constant 5\sqrt 5 is best possible: for the golden ratio φ=1+52=[1;1,1,… ]\varphi = \tfrac{1+\sqrt 5}{2} = [1;1,1,\dots], any larger constant C>5C > \sqrt 5 admits only finitely many solutions to ∣x−p/q∣<1/(Cq2)|x - p/q| < 1/(Cq^2). Derivation hint: among any three consecutive convergents at least one beats 1/5q21/\sqrt5 q^2, shown by the identity relating qn−1/qnq_{n-1}/q_n ratios; for optimality use that xn+1→φx_{n+1} \to \varphi for the golden ratio so the constant saturates at 5\sqrt5.

Why It Holds

ProofBest Approximation Property — Equation 7

Step 1. Suppose p/qp/q is in lowest terms with ∣x−p/q∣<1/(2q2)|x - p/q| < 1/(2q^2), and assume for contradiction p/qp/q is not a convergent. Choose nn so that qn≤q<qn+1q_n \le q < q_{n+1} (possible since the qnq_n strictly increase for n≥1n \ge 1).

Step 2. By the best-approximation theorem, ∣qnx−pn∣≤∣qx−p∣|q_n x - p_n| \le |q x - p|. Multiply the hypothesis by qq: ∣qx−p∣<1/(2q)|qx - p| < 1/(2q).

Step 3. Consider the integer N=pqn−pnqN = p q_n - p_n q. Since p/q≠pn/qnp/q \ne p_n/q_n (else p/qp/q is a convergent), N≠0N \ne 0, so ∣N∣≥1|N| \ge 1. Write

9
Nqqn=pq−pnqn=(pq−x)+(x−pnqn).\quad \frac{N}{q q_n} = \frac{p}{q} - \frac{p_n}{q_n} = \left(\frac{p}{q} - x\right) + \left(x - \frac{p_n}{q_n}\right).

Derivation hint: add and subtract xx; the left equality is just clearing denominators.

Step 4. Bound the right side using the triangle inequality, the hypothesis, and [6]:

10
1qqn≤∣Nqqn∣<12q2+1qnqn+1≤12q2+1qqn⋅qqn+1.\quad \frac{1}{q q_n} \le \left|\frac{N}{q q_n}\right| < \frac{1}{2q^2} + \frac{1}{q_n q_{n+1}} \le \frac{1}{2q^2} + \frac{1}{q q_n}\cdot\frac{q}{q_{n+1}}.

Derivation hint: ∣x−pn/qn∣<1/(qnqn+1)|x - p_n/q_n| < 1/(q_n q_{n+1}) by [6], and qn≤qq_n \le q.

Step 5. Since q<qn+1q < q_{n+1}, we get q/qn+1<1q/q_{n+1} < 1, and careful comparison (multiplying through by qqnq q_n and using qn≤qq_n \le q) forces 1<qn/(2q)+11 < q_n/(2q) + 1, a contradiction once the strict inequalities are tracked. Hence p/qp/q must be a convergent. ■\blacksquare

∎
ProofThe ≤1/qn2\le 1/q_n^2 bound — Equation 6

Step 1. Use the tail representation: writing xn+1=[an+1;an+2,… ]x_{n+1} = [a_{n+1}; a_{n+2}, \dots] (the complete quotient), the algorithm gives exactly

11
x=xn+1pn+pn−1xn+1qn+qn−1.\quad x = \frac{x_{n+1} p_n + p_{n-1}}{x_{n+1} q_n + q_{n-1}}.

Derivation hint: apply [3] with the real value xn+1x_{n+1} in place of an integer an+1a_{n+1}; this is the same matrix recurrence evaluated at a real partial quotient.

Step 2. Subtract pn/qnp_n/q_n and clear denominators:

12
x−pnqn=(pnqn−1−pn−1qn) (−1)qn(xn+1qn+qn−1)=(−1)nqn(xn+1qn+qn−1).\quad x - \frac{p_n}{q_n} = \frac{(p_n q_{n-1}-p_{n-1}q_n)\,(-1)}{q_n(x_{n+1}q_n + q_{n-1})} = \frac{(-1)^n}{q_n(x_{n+1}q_n + q_{n-1})}.

Derivation hint: combine [11] over common denominator qnq_n, simplify the numerator using the determinant identity [4].

Step 3. Since xn+1>an+1≥1x_{n+1} > a_{n+1} \ge 1, the denominator exceeds qn(qn+qn−1)≥qn⋅qnq_n(q_n + q_{n-1}) \ge q_n \cdot q_n (in fact xn+1qn+qn−1>qn+1x_{n+1}q_n + q_{n-1} > q_{n+1}), giving the upper bound 1/(qnqn+1)≤1/qn21/(q_n q_{n+1}) \le 1/q_n^2. The lower bound follows since xn+1<an+1+1x_{n+1} < a_{n+1}+1 implies the denominator <qn(qn+1+qn)< q_n(q_{n+1}+q_n). ■\blacksquare

∎
mathematician · Aleksandr Khinchin | 1894–1959

Khinchin transformed continued fractions from a computational curiosity into a branch of metric number theory — the study of properties holding for almost all reals in the Lebesgue sense. His 1935 monograph Continued Fractions proved that for almost every xx the geometric mean of the partial quotients a1a2⋯ann\sqrt[n]{a_1 a_2 \cdots a_n} converges to a universal constant K0K_0, independent of xx, and established the ergodicity of the Gauss map G(x)={1/x}G(x) = \{1/x\} with respect to the Gauss measure dμ=1ln⁡2dx1+xd\mu = \frac{1}{\ln 2}\frac{dx}{1+x}. His work bridged probability theory (he proved the law of the iterated logarithm) and arithmetic, showing the continued fraction algorithm is a measure-preserving dynamical system. The Gauss–Kuzmin–Wirsing operator governing the convergence rate is named partly for his program.

Building Intuition

🧠 Intuition

Picture the Stern–Brocot tree or the Farey sequence: rationals organized by denominator. To approximate xx, you descend the tree, at each node turning left (toward smaller) or right (toward larger). The partial quotients ana_n count how many consecutive turns in the same direction you make before xx forces you to switch. A large ana_n means xx sits very near a "shelf" — a low-denominator rational that approximates it well, so you can stay close for a long time before refining. This is why π=[3;7,15,1,292,… ]\pi = [3;7,15,1,292,\dots] has the famous 355/113355/113 approximation: the partial quotient 292292 is enormous, so 355/113355/113 (the convergent just before that big jump) is spectacularly accurate. Conversely, φ=[1;1,1,1,… ]\varphi = [1;1,1,1,\dots] has the smallest possible partial quotients everywhere, so it is the hardest number to approximate — the convergents improve as slowly as the theory permits. Geometrically (the Klein/Lagrange picture), the convergents are the lattice points closest to the line y=xy = x in Z2\mathbb{Z}^2, alternating above and below; the partial quotients record how the line cuts successive cells of the integer lattice.

Figure
Convergents straddling the target xx with shrinking error windows

```svg

Convergents p_n/q_n oscillate toward x number line x (irrational) p0/q0 p2/q2 p4/q4 p1/q1 p3/q3 error < 1/(q_n q_{n+1}) shrinks each step

```

Worked Examples

ExampleContinued fraction of 2\sqrt{2} and its convergents

Given: x=2≈1.41421356x = \sqrt 2 \approx 1.41421356.

Step 1 — run the algorithm. a0=⌊2⌋=1a_0 = \lfloor\sqrt2\rfloor = 1; x1=1/(2−1)=2+1≈2.4142x_1 = 1/(\sqrt2 - 1) = \sqrt2 + 1 \approx 2.4142. Then a1=2a_1 = 2, x2=1/(x1−2)=1/(2−1)=2+1x_2 = 1/(x_1 - 2) = 1/(\sqrt2 - 1) = \sqrt2 + 1. The process now repeats: 2=[1;2,2,2,… ]=[1;2‾]\sqrt 2 = [1; 2,2,2,\dots] = [1;\overline 2] (purely periodic tail — this is a quadratic irrational, by Lagrange's theorem).

Step 2 — build convergents via [3]. With a=(1,2,2,2,2)a = (1,2,2,2,2):

nnana_npnp_nqnq_npn/qnp_n/q_n
01111.00001.0000
12321.50001.5000
22751.40001.4000
3217121.416‾1.41\overline{6}
4241291.4137931.413793

Step 3 — check error bound [6]. For n=4n=4: ∣2−41/29∣≈4.20×10−4|{\sqrt2} - 41/29| \approx 4.20\times10^{-4}, while 1/q42=1/841≈1.19×10−31/q_4^2 = 1/841 \approx 1.19\times10^{-3}. Indeed the error is below the bound.

2=[1;2‾],p4q4=4129,∣2−4129∣≈4.2×10−4\boxed{\sqrt 2 = [1;\overline{2}], \quad \frac{p_4}{q_4} = \frac{41}{29}, \quad \left|\sqrt2 - \tfrac{41}{29}\right| \approx 4.2\times10^{-4}}

(Note: pn,qnp_n, q_n here solve Pell's equation p2−2q2=±1p^2 - 2q^2 = \pm1, e.g. 412−2⋅292=1681−1682=−141^2 - 2\cdot29^2 = 1681 - 1682 = -1.)

ExampleWhy 355/113355/113 approximates π\pi so well

Given: π=[3;7,15,1,292,1,1,… ]\pi = [3; 7, 15, 1, 292, 1, 1, \dots].

Step 1 — first few convergents.

  • [3]=3/1[3] = 3/1
  • [3;7]=22/7≈3.142857[3;7] = 22/7 \approx 3.142857 (error ≈1.26×10−3\approx 1.26\times10^{-3})
  • [3;7,15]=333/106≈3.141509[3;7,15] = 333/106 \approx 3.141509 (error ≈8.3×10−5\approx 8.3\times10^{-5})
  • [3;7,15,1]=355/113≈3.1415929[3;7,15,1] = 355/113 \approx 3.1415929 (error ≈2.67×10−7\approx 2.67\times10^{-7})

Step 2 — explain the jump. The next partial quotient is a4=292a_4 = 292 (very large). By [6], ∣π−355/113∣<1/(q3q4)|\pi - 355/113| < 1/(q_3 q_4) with q3=113q_3 = 113 and q4=a4q3+q2=292⋅113+106=33102q_4 = a_4 q_3 + q_2 = 292\cdot113 + 106 = 33102. So the error is below 1/(113⋅33102)≈2.67×10−71/(113 \cdot 33102) \approx 2.67\times10^{-7} — an error one would naively expect only from a five-digit denominator, achieved with a three-digit one.

Step 3 — verify the best-approximation strength. Compare 1/(2q2)=1/(2⋅1132)≈3.9×10−51/(2q^2) = 1/(2\cdot113^2) \approx 3.9\times10^{-5}. Since the actual error 2.67×10−7<3.9×10−52.67\times10^{-7} < 3.9\times10^{-5}, equation [7] confirms 355/113355/113 must be a convergent — consistent.

355113≈π to 6 decimal places; the large a4=292 is the cause\boxed{\frac{355}{113} \approx \pi \text{ to } 6 \text{ decimal places; the large } a_4 = 292 \text{ is the cause}}

Common Misconceptions

⚠️ Common mistake

Convergents are not the only good approximations, but they bracket them. Between consecutive convergents lie the intermediate (semi-)convergents pn−1+k pnqn−1+k qn\frac{p_{n-1} + k\,p_n}{q_{n-1} + k\,q_n} for 1≤k<an+11 \le k < a_{n+1}. These can be best approximations of the first kind (minimizing ∣x−p/q∣|x - p/q|) without being convergents. Do not assume every excellent rational approximation appears in the convergent list — only the best approximations of the second kind (minimizing ∣qx−p∣|qx-p|) are exactly the convergents.

⚠️ Common mistake

The bound [7] is sufficient but not necessary. A fraction can be a convergent yet fail ∣x−p/q∣<1/(2q2)|x - p/q| < 1/(2q^2) — e.g. when the next partial quotient is 11, a convergent may only achieve ≈1/q2\approx 1/q^2, not 1/2q21/2q^2. Equation [7] guarantees "convergent ⇒\Rightarrow good" in reverse direction only: good ⇒\Rightarrow convergent.

CounterexampleNot every quadratic irrational is "badly approximable" trivially

One might guess that purely periodic continued fractions correspond exactly to "simple" numbers. But consider x=[1,2‾]=3−11⋅…x = [\overline{1,2}] = \frac{\sqrt 3 - 1}{1}\cdot\dots — its partial quotients are bounded (≤2\le 2), so it is badly approximable (bounded partial quotients   ⟺  \iff xx avoids approximation better than c/q2c/q^2). Yet e=[2;1,2,1,1,4,1,1,6,… ]e = [2;1,2,1,1,4,1,1,6,\dots] has unbounded partial quotients (the 2k2k terms grow), so ee is not badly approximable despite being a "natural" constant — it admits infinitely many approximations far better than φ\varphi allows. The lesson: approximability is governed by partial quotient growth, not by how "famous" or "algebraic-looking" the number is.

Connections

connection

Continued fractions sit at a crossroads of analysis, algebra, and dynamics. Lagrange's theorem ties them to Quadratic Irrationals: xx has an eventually periodic continued fraction iff xx is a quadratic irrational, linking the theory to Pell's Equation and the units of real quadratic fields. The Gauss map G(x)={1/x}G(x) = \{1/x\} realizes the shift on partial quotients as a chaotic ergodic dynamical system, placing continued fractions inside Symbolic Dynamics. The approximation hierarchy generalizes through Diophantine Approximation to Liouville's theorem (algebraic numbers of degree dd resist approximation beyond exponent dd) and its deep refinement, the Thue–Siegel–Roth Theorem (algebraic irrationals have approximation exponent exactly 22). The metric theory connects to Hausdorff Dimension via the dimensions of sets with prescribed partial-quotient growth, and to Continued Fraction Transformation / transfer operators. Finally, the modular group SL2(Z)\mathrm{SL}_2(\mathbb{Z}) acting on the hyperbolic plane geometrizes the whole subject: convergents are cusps of geodesics, tying continued fractions to Hyperbolic Geometry and Modular Forms.

Real-World Applications

🔬 Where this appears

Historical Development

⏳ History
- c. 300 BCE — Euclid. The Euclidean algorithm for GCDs is implicitly the terminating continued fraction algorithm for rationals.
- 499 CE — Aryabhata. Used a method (kuttaka) equivalent to continued fractions to solve linear Diophantine equations.
- 1572 — Bombelli. Approximated 13\sqrt{13} with what amounts to a continued fraction.
- 1655–1695 — Wallis & Brouncker. Brouncker gave the celebrated continued fraction for 4/π4/\pi; Wallis coined "continued fraction" and proved early recurrence relations in his Arithmetica Infinitorum.
- 1737–1748 — Euler. Proved e=[2;1,2,1,1,4,… ]e = [2;1,2,1,1,4,\dots], established the recurrence [3], and showed periodic continued fractions give quadratic irrationals (one direction of Lagrange's theorem).
- 1768–1770 — Lagrange. Proved the converse: every quadratic irrational has an eventually periodic continued fraction. Applied the method to Pell's equation and to bounding roots of polynomials.
- 1813 — Gauss. Discovered the invariant measure 1ln⁡2dx1+x\frac{1}{\ln 2}\frac{dx}{1+x} for the Gauss map and posed (in a letter to Laplace) the Gauss–Kuzmin problem on the distribution of partial quotients.
- 1844 — Liouville. Used continued fractions / approximation exponents to construct the first explicit transcendental numbers, proving algebraic numbers cannot be too well approximated.
- 1891 — Hurwitz. Proved the optimal constant 5\sqrt5 (equation [8]) and identified the golden ratio as the extremal case.
- 1928–1935 — Kuzmin, Lévy, Khinchin. Kuzmin proved Gauss's conjecture with an error term; Khinchin established the universal constant K0K_0 and ergodicity; Lévy found the a.e. growth rate qn1/n→eπ2/(12ln⁡2)q_n^{1/n} \to e^{\pi^2/(12\ln 2)}.
- 1955 — Roth. Proved the Thue–Siegel–Roth theorem (Fields Medal 1958): algebraic irrationals have approximation exponent exactly 22, the sharpest possible refinement of Liouville, sharp because of Hurwitz.

Subtleties & Limits

open-problem

Deep questions remain about the partial quotients of specific natural constants. It is unknown whether the partial quotients of π\pi, e2/3e^{2/3} wait—ee's pattern is known, but for π\pi, γ\gamma (Euler–Mascheroni), 23\sqrt[3]{2}, and almost all algebraic numbers of degree ≥3\ge 3, it is conjectured but unproven that the partial quotients are unbounded (i.e. these numbers are not badly approximable). The Zaremba conjecture asks whether for some absolute bound BB, every integer qq is the denominator of a fraction whose continued fraction has all partial quotients ≤B\le B — proven only for density-one sets of qq (Bourgain–Kontorovich, 2014). The Littlewood conjecture on simultaneous approximation, lim inf⁡q→∞q ∥qα∥ ∥qβ∥=0\liminf_{q\to\infty} q\,\|q\alpha\|\,\|q\beta\| = 0 for all α,β\alpha,\beta, is intimately connected to continued fractions of α,β\alpha,\beta and remains open despite the Einstein–Katok–Lindenstrauss measure-rigidity progress showing the exceptional set has Hausdorff dimension zero. Finally, whether Khinchin's constant K0K_0 is itself "normal" or even irrational is unknown — a striking gap, since K0K_0 governs almost every number yet resists analysis as an individual constant.

See Also

Diophantine Approximation · Quadratic Irrationals · Gauss–Kuzmin Distribution · Khinchin's Constant · Pell's Equation · Thue–Siegel–Roth Theorem · Farey Sequence · Stern–Brocot Tree · Modular Group · Liouville Numbers