Skip to content

Continued Fractions

Definition. For integers a0,a1,…,ana_0, a_1, \ldots, a_n with ai>0a_i > 0 for i≥1i \geq 1,

[a0;a1,a2,…,an]=a0+1a1+1a2+⋯+1an[a_0; a_1, a_2, \ldots, a_n] = a_0 + \cfrac{1}{a_1 + \cfrac{1}{a_2 + \cdots + \cfrac{1}{a_n}}}

Every rational number has exactly two such expansions; the last term must exceed 1, and one of [a0;…,an][a_0; \ldots, a_n] vs [a0;…,an−1,1][a_0; \ldots, a_n - 1, 1] is chosen by convention:

4319=[2;3,1,4]:43/19=2+519,  19/5=3+45,  5/4=1+14,  4.\frac{43}{19} = [2; 3, 1, 4]: \quad 43/19 = 2 + \tfrac{5}{19},\; 19/5 = 3 + \tfrac45,\; 5/4 = 1 + \tfrac14,\; 4.

The convergents pk/qk=[a0;a1,…,ak]p_k/q_k = [a_0; a_1, \ldots, a_k] satisfy the recurrences

pk=akpk−1+pk−2,qk=akqk−1+qk−2,p_k = a_k p_{k-1} + p_{k-2}, \qquad q_k = a_k q_{k-1} + q_{k-2},

with p−1=1,p0=a0p_{-1} = 1, p_0 = a_0, q−1=0,q0=1q_{-1} = 0, q_0 = 1. Two classical identities:

pkqk−1−pk−1qk=(−1)k−1,pkqk−2−pk−2qk=(−1)kak.p_k q_{k-1} - p_{k-1} q_k = (-1)^{k-1}, \qquad p_k q_{k-2} - p_{k-2} q_k = (-1)^k a_k.

Convergents are best rational approximations: pk/qkp_k/q_k is closer to the true value than any fraction with denominator ≤qk\leq q_k. This is why continued fractions convert decimal approximations into “likely” rationals; a standard exam task (feed π≈3.14159\pi \approx 3.14159 and recover 22/722/7, 355/113355/113).

For irrational α\alpha the expansion is infinite and the convergents converge to α\alpha (monotone even/odd subsequences, with ∣pk/qk−α∣<1qkqk+1|p_k/q_k - \alpha| < \frac{1}{q_k q_{k+1}}).

Irrational quadratic surds have eventually periodic expansions; and conversely:

7=[2;1,1,1,4‾],13=[3;1,1,1,1,6‾].\sqrt{7} = [2; \overline{1, 1, 1, 4}], \qquad \sqrt{13} = [3; \overline{1, 1, 1, 1, 6}].

This is the algorithmic heart of Pell’s equation (Pell’s Equation and Sums of Squares): period length parity decides solvability of x2−Dy2=±1x^2 - Dy^2 = \pm 1, and convergents at period boundaries are the solutions.

The most famous infinite expansion:

e=[2;1,2,1,1,4,1,1,6,1,…],π has no known pattern.e = [2; 1, 2, 1, 1, 4, 1, 1, 6, 1, \ldots], \qquad \pi \text{ has no known pattern}.

Problem 1. Expand 2=[1;2‾]\sqrt{2} = [1; \overline{2}].

Let x=1+1xx = 1 + \frac{1}{x} (the periodic self-similarity: 2=1+(2−1)\sqrt 2 = 1 + (\sqrt 2 - 1) and 2+1=1/(2−1)\sqrt 2 + 1 = 1/\left(\sqrt 2 - 1\right)). Then x2=x+1x^2 = x + 1, so x=1+52x = \frac{1+\sqrt5}{2} - the golden ratio φ=[1;1,1,…]\varphi = [1; 1, 1, \ldots]: the “slowest” continued fraction, and why its convergents (Fibonacci ratios) are the worst approximable numbers. For 2\sqrt 2: x=[1;2‾]x = [1;\overline 2] follows from x=1+12+1x−1x = 1 + \frac{1}{2 + \frac{1}{x - 1}}-style substitution - compute the expansion directly by the standard algorithm:

a0=1a_0 = 1, m1=1m_1 = 1, d1=1d_1 = 1, a1=⌊(1+1)/1⌋=2a_1 = \lfloor (1 + 1)/1 \rfloor = 2; iterate mk+1=dkak−mkm_{k+1} = d_k a_k - m_k, dk+1=(D−mk+12)/dkd_{k+1} = (D - m_{k+1}^2)/d_k, ak+1=⌊(a0+mk+1)/dk+1⌋a_{k+1} = \lfloor (a_0 + m_{k+1})/d_{k+1} \rfloor.

Problem 2. Compute convergents of [1;2,2,2][1; 2, 2, 2] and bound the error.

p0/q0=1/1p_0/q_0 = 1/1, p1/q1=3/2p_1/q_1 = 3/2, p2/q2=7/5p_2/q_2 = 7/5, p3/q3=17/12p_3/q_3 = 17/12; check 17/12=1.416‾17/12 = 1.41\overline{6} vs 2=1.41421…\sqrt 2 = 1.41421\ldots; error <112⋅29< \frac{1}{12 \cdot 29} by the identity p3q2−p2q3=(−1)3p_3 q_2 - p_2 q_3 = (-1)^3.

  • Every finite expansion terminates in a rational: irrationals have infinite expansions.
  • Convergent denominators grow at least like Fibonacci numbers (all ak=1a_k = 1 worst case, golden ratio); quoting this justifies “best approximation” claims.
  • Periodic expansions detect degree-2 irrationals exactly: 23\sqrt[3]{2} is neither rational nor quadratic, so its expansion is aperiodic; do not claim periodicity for cube roots.
  • The final partial quotient convention: forbid an=1a_n = 1 in canonical form or you get two valid expansions and inconsistent convergent tables.
∣α−pkqk∣<1qkqk+1≤1qk2\left| \alpha - \frac{p_k}{q_k} \right| < \frac{1}{q_k q_{k+1}} \leq \frac{1}{q_k^2}

This bound is the theorem behind “best rational approximation”: every convergent beats every fraction with a smaller denominator. A typical exam question supplies a decimal expansion and a denominator bound and asks you to recover the fraction; the method is to expand the decimal as a continued fraction and stop at the last convergent within the bound.

For periodic expansions, quote the structure: D\sqrt{D} has partial quotients generated by the recurrence on mk,dk,akm_k, d_k, a_k, the period begins at a1a_1, and the last term of the period is always 2a02a_0. Citing these facts precisely earns the method marks even when the arithmetic is long.