The analysis in this chapter illustrates Temple’s observation regarding the necessity for creative imagination in mathematics. A simple expression is all that is needed to develop the theory of continued fractions which leads to a deep theorem of Lagrange and also leads to an optimal way to approximate real numbers as rational fractions.

To proceed, assume that f(x) is a positive function. Obviously

$$\displaystyle \begin{aligned} (1 + f(x)) f(x) = f(x) + f^2(x) \end{aligned}$$

which implies that

(10.1)

This rearrangement of symbols seems like nonsense which has no possibility of yielding a meaningful result. Before concluding this, however, consider the case where \(f(x) = \sqrt {x}\). Equation (10.1) then yields

(10.2)

which expresses \(\sqrt {x}\) in terms of itself. This means that substituting the right-hand side of (10.2) for the occurrence of \(\sqrt {x}\) appearing in the denominator results in

Continuing in this way another time shows that

(10.3)

and now a pattern is clear. Expressing a function in terms of itself leads to a regression. If the function appears in the denominator of the expression, then the resultant expansion is called a continued fraction. On first encounter, the infinite descent of fractions that threaten to run off the page appear to be inane. Changing notation can solve this run away train problem, but to show that continued fractions are anything but inane requires the rest of this chapter.

10.1 Simple Continued Fractions

A special case, termed a simple continued fraction, restricts all numerators to equal 1. This is denoted by

(10.4)

With this notation, equation (10.3) with x = 2 shows that

$$\displaystyle \begin{aligned} \sqrt{2} = [1, 2, \ldots ] \end{aligned} $$
(10.5)

To simplify notation an underline is used to represent periodic arguments. Thus, a more succinct expression of (10.5) is given by

$$\displaystyle \begin{aligned} \sqrt{2} = [1,\underline{2}] \end{aligned} $$
(10.6)

Some algebraic properties follow directly from definition (10.4) which can be summarized by the following identities:

(10.7)
$$\displaystyle \begin{aligned}{}[{b_0}, b_1, \ldots, b_{k-1}, \ b_{k}] = [{b_0}, b_1, \ldots ,b_{k-2}, \ b_{k-1} + 1/b_{k}] \end{aligned} $$
(10.8)
$$\displaystyle \begin{aligned}{}[{b_0},b_1, b_2, \ldots , b_{n-1}, b_{n}, \ldots] = [{b_0},b_1, b_2, \ldots , b_{n-1}, [b_{n},b_{n+1}, \ldots] ] \end{aligned} $$
(10.9)
$$\displaystyle \begin{aligned} \frac{1}{[{0},b_1, b_2, \ldots ]}= [b_1, b_2, \ldots ] \end{aligned} $$
(10.10)

To generalize the form of equation (10.6), consider the continued fraction \([a, \underline {b} ]\) where a and b are non-zero integers. To derive an equation for this form, use (10.7) to write

(10.11)

and

where \(\alpha = [ \underline {b}]\). This creates the quadratic equation

$$\displaystyle \begin{aligned} \alpha^2 = b \alpha + 1 \end{aligned} $$
(10.12)

where only the positive solution is applicable:

Substituting this solution into (10.11) produces an equation for \([a, \underline {b} ] \):

(10.13)

Special cases of (10.13) that involve square roots are depicted in the following table:

Constant

Periodic Portion

Value

1

\([ \underline {2}]\)

\( \sqrt {2}\)

2

\([ \underline {4}]\)

\(\sqrt {5}\)

3

\([ \underline {6}]\)

\(\sqrt {10}\)

4

\([ \underline {8}]\)

\(\sqrt {17}\)

5

\([ \underline {10}]\)

\(\sqrt {26}\)

6

\([ \underline {12}]\)

\(\sqrt {37}\)

7

\([ \underline {14}]\)

\(\sqrt {50}\)

8

\([ \underline {16}]\)

\(\sqrt {65}\)

9

\([ \underline {18}]\)

\(\sqrt {82}\)

Purely Periodic

1

\({ [ \underline {\mathbf {1}}]}\)

\({ (\mathbf {1} + \sqrt {\mathbf {5}})/\mathbf {2}}\)

2

\([ \underline {2}]\)

\(1 + \sqrt {2}\)

3

\([ \underline {3}]\)

\((3 + \sqrt {13})/2\)

4

\([ \underline {4}]\)

\(2 + \sqrt {5}\)

5

\([ \underline {5}]\)

\((5 + \sqrt {29})/2\)

6

\([ \underline {6}]\)

\(3 + \sqrt {10}\)

7

\([ \underline {7}]\)

\((7 + \sqrt {53})/2\)

8

\([ \underline {8}]\)

\(4 + \sqrt {17}\)

9

\([ \underline {9}]\)

\((9 + \sqrt {85})/2\)

The last section of the table deals with the special case of purely periodic continued fractions with unit period length. The first entry of that section of the table highlights the exquisitely beautiful example of an infinite continued fraction: that of the golden ratioFootnote 1

$$\displaystyle \begin{aligned} \phi = [\underline{1} ] = (1 + \sqrt{5})/2 \end{aligned} $$
(10.14)

Before delving deeper into the patterns depicted in the above table, consider continued fractions having a periodic pattern of length of 2 given by \([a, \underline {b_0, b_1} ]\). Let \(\alpha = [ \underline {b_0, b_1}]\) and write:

(10.15)

The resultant quadratic equation

$$\displaystyle \begin{aligned} \alpha^2 = b_0 \alpha+ b_0/b_1 \end{aligned}$$

is a generalization of (10.12) with the solution

The final expression is thus given by

(10.16)

Continuing the special cases that involve square roots expands the previous table to include:

Constant

Periodic Portion

Value

1

\([ \underline {1,2}]\)

\( \sqrt {3}\)

2

\([ \underline {2,4}]\)

\(\sqrt {6}\)

3

\([ \underline {3,6}]\)

\(\sqrt {11}\)

4

\([ \underline {4,8}]\)

\(\sqrt {18}\)

5

\([ \underline {5,10}]\)

\(\sqrt {27}\)

6

\([ \underline {6,12}]\)

\(\sqrt {38}\)

7

\([ \underline {7,14}]\)

\(\sqrt {51}\)

8

\([ \underline {8,16}]\)

\(\sqrt {66}\)

9

\([ \underline {9,18}]\)

\(\sqrt {83}\)

The path to generalizing these results to periodic sections with longer length seems clear but the necessary algebra that mimics the expansion of (10.15) soon gets out of hand. To derive a method to handle this algebra, consider the series of convergents given by

To establish the general pattern for these convergents, let n i and d i denote the numerator and denominator of the i’th convergent of [b 0, b 1, …, b i]. Initial values include n 1 = b 0b 1 + 1, d 1 = b 1 and

and

These examples show that the numerator and denominator satisfy the general recurrence, x i = b ix i−1 + x i−2, where each starts with different initial values

$$\displaystyle \begin{aligned} n_{-1} = 1, \ n_0 = {b_0} \ \ \ {\mathrm{and}} \ \ \ d_{-1} = 0, \ d_0 = 1 \end{aligned}$$

The following inductive argument will establish this recurrence relationship. Assume that the recurrence holds for all cases up to some value k. Use (10.8) to write

This shows the pattern continuing to the k + 1’st case and establishes the general expression

(10.17)

Note that, for i = 0, these equations yield n 0d 0 = b 0 Footnote 2.

One further relationship will prove to be useful. Define

$$\displaystyle \begin{aligned} \alpha_j = [b_j, b_{j+1}, \ldots ] \end{aligned}$$

and use equation (10.9) to write

$$\displaystyle \begin{aligned} \alpha_0 = [ b_0 , \ldots ] = [ b_0, \ldots b_{i }, \alpha_{i+1} ] , \ \ \ i=0, \ldots \end{aligned}$$

Treating α i+1 as if it were the last part of the continued fraction permits expressing α 0 as

(10.18)

where (10.18) is not necessarily rational.

10.1.1 Periodic Simple Continued Fractions

To proceed with an investigation of simple continued fractions that are periodic, let α be defined by

$$\displaystyle \begin{aligned} {\alpha} = [\underline{b_0, b_1, \ldots , b_{k}} ] \end{aligned} $$
(10.19)

Equation (10.18) shows that

(10.20)

where the convergents arise from equation (10.19). Equation (10.20) corresponds to the quadratic equation

$$\displaystyle \begin{aligned} {d}_{k} {\alpha}^2 - ({n}_{k} - {d}_{k-1} ) {\alpha} - {n}_{k-1} = 0 \end{aligned} $$
(10.21)

which has the solution

(10.22)

Collecting these results implies that

(10.23)

This equation can be used to fill out some of the square roots that were missing from the previous tables:

Constant

Periodic Portion

Value

2

\([ \underline {1,1,1,4}]\)

\( \sqrt {7}\)

3

\([ \underline {1,1,1,1,6}]\)

\(\sqrt {13}\)

3

\([ \underline {1,2,1,6}]\)

\(\sqrt {14}\)

4

\([ \underline {2,1,3,1,2,8}]\)

\(\sqrt {19}\)

4

\([ \underline {1,1,2,1,1,8}]\)

\(\sqrt {21}\)

4

\([ \underline {1,2,4,2,1,8}]\)

\(\sqrt {22}\)

4

\([ \underline {1,3,1,8}]\)

\(\sqrt {23}\)

5

\([ \underline {3,2,3,10}]\)

\(\sqrt {28}\)

5

\([ \underline {1,1,3,5,3,1,1,10}]\)

\(\sqrt {31}\)

5

\([ \underline {1,1,1,10}]\)

\(\sqrt {32}\)

5

\([ \underline {1,2,1,10}]\)

\(\sqrt {33}\)

5

\([ \underline {1,4,1,10}]\)

\(\sqrt {34}\)

6

\([ \underline {2,2,12}]\)

\(\sqrt {41}\)

6

\([ \underline {1,1,3,1,5,1,3,1,1,12}]\)

\(\sqrt {43}\)

6

\([ \underline {1,1,1,2,1,1,1,12}]\)

\(\sqrt {44}\)

6

\([ \underline {1,2,2,2,1,12}]\)

\(\sqrt {45}\)

6

\([ \underline {1,3,1,1,2,6,2,1,1,3,1,12}]\)

\(\sqrt {46}\)

6

\([ \underline {1,5,1,12}]\)

\(\sqrt {47}\)

10.1.2 Summary of Results

The patterns depicted in the three previous tables show that there appears to be a relationship between square roots of non-square integers and continued fractions that have periodic sections from some point onward. For decimal numbers, such as \(2/3 = . \underline {6}\) or \(7/12 = .58 \underline {3}\), cyclic patterns of this type arise if and only if the number is rational. Is there an analogous theorem for periodic continued fractions?

The entries in the tables also suggest that, if there were such a pattern, then it would pertain to irrational, rather than to rational, numbers. This follows from the fact that the square root of non-square integers is irrational.Footnote 3 There is also a curious form to the square root examples especially revealed in the last table: the last number in the periodic section equals twice the first number of the fraction, b k = 2a, and the numbers in the periodic section (not including the last) form a palindrome: b i = b ki−1, i = 0, …, k − 1. All of these observations lead us to the question: Is something deeper at hand?

In fact there is. These preliminary results are examples of special cases of a theorem of Lagrange that established that solutions to quadratic equations with a non-square discriminant and integer coefficientsFootnote 4 have continued fractions that are periodic from some point onward. This is the analogy of the theorem for decimal expansions regarding rational numbers. Equation (10.23) is one part of Lagrange’s theorem. The remaining parts will fall into place over the next few pages. The structure of the repeating portion of square roots follows as a special case of the theorem. These results are surprising and beautiful. Why would a value that is a solution to a particular type of quadratic equation impose a periodic structure on its continued fraction expansion?

There are still some results which are required to derive the necessary part of Lagrange’s theorem (which was formally proved by Galois ). First, a method that creates a continued fraction representation for an arbitrary number must be created. After this is completed, properties of purely periodic continued fractions are analyzed. Like periodic decimal expansions, such as \(1/7 = . \underline {142857}\), purely periodic continued fractions do not have a non-periodic preamble which implies they can be written as \([ \underline {b_0, b_1, \ldots , b_{\ell -1}}]\) for some period length . These investigations will then provide the apparatus needed to prove Lagrange’s theorem.

10.2 General Method to Create a Continued Fraction

Let ⌊x⌋ be the integer component of positive value x, for example ⌊1.4142135⌋ = 1, and let r(x) = x −⌊x⌋ be the decimal component of x, for example r(1.4142135) = .4142135. Clearly x = ⌊x⌋ + r(x) and r(x) satisfies 0 ≤ r(x) < 1. Provided that r(x)≠0 this implies that 1∕r(x) is greater than 1 which shows that

(10.24)

We can use this equation as an operation to create a continued fraction expansion. Applying the operation on the denominator of (10.24) highlights the technique:

To recursively write the continued fraction expansion resulting from repeatedly applying (10.24), let b 0 = ⌊x⌋. Let ψ 0 = 1∕r(x) and for i ≥ 1 define

$$\displaystyle \begin{aligned} b_i = \lfloor \psi_{i-1} \rfloor \end{aligned} $$
(10.25)

and

$$\displaystyle \begin{aligned} \psi_i = 1/ r(\psi_{i-1}) \end{aligned} $$
(10.26)

The recursion ends when the remainder in the denominator of (10.26) equals 0. With this notation, a continued fraction expression for x can be expressed as

$$\displaystyle \begin{aligned} x = [{b_0}, b_1, \ldots , b_n] \end{aligned}$$

where n is finite if x is a rational number (irrational numbers obviously have infinite continued fraction expansions). Checking this recursion for the golden ratio (10.14) shows that b 0 = ⌊ϕ⌋ = 1 and

$$\displaystyle \begin{aligned} \psi_0 = \frac{1}{ r(\phi)} = \frac{1}{\phi - \left \lfloor \phi \right \rfloor} = \frac{2}{\sqrt{5} - 1} =\phi \end{aligned}$$

(the last equality was also derived in equation (5.4)). This shows that b 1 = ⌊ϕ⌋ = 1. Repeating this process leads to the previously derived equation, \(\phi = [ \underline {1}]\).

In this example, successive iterates of equation (10.26) created a periodic sequence of unit length so that ψ i+1 = ψ i for all i ≥ 0. Suppose, instead of unit length, the sequence generated a period of length so that ψ i+ = ψ i for i ≥ 0. Then the resultant continued fraction expansion would be purely periodic with length . To explore conditions where this occurs we next discuss properties of quadratic irrational numbers.

10.2.1 Integer Quadratics and Quadratic Surds

The quadratic equation

$$\displaystyle \begin{aligned} a x^2 + b x + c = 0 \end{aligned}$$

has two solutions given by

$$\displaystyle \begin{aligned} r^\pm = \frac{-b \pm \sqrt{b^2 - 4 a c} }{2 a} \end{aligned} $$
(10.27)

Let an integer quadratic be a quadratic equation where its coefficients, a, b and c, are integers that satisfy a > 0 and b 2 + 4ac is not square (this last expression is termed the discriminate). Quadratic irrational numbers are typically represented in the form

$$\displaystyle \begin{aligned} \chi^\pm = \frac{\alpha \pm \sqrt{\beta}}{\gamma} \end{aligned} $$
(10.28)

where α and γ are rational numbers and β is a non-square integer. The value \(\chi ^- = (\alpha - \sqrt {\beta })/\gamma \) is said to be the conjugate of \(\chi ^+ = (\alpha + \sqrt {\beta })/\gamma \). (Similarly χ + is said to be the conjugate of χ .)

For every solution to an integer quadratic equation there corresponds a unique quadratic irrational number. This follows by setting α = −b, γ = a, and β = b 2 − 4ac which shows that χ ± = r ±. Conversely, for every quadratic irrational number there corresponds a unique integer quadratic equation (this is true up to a multiplicative constant). To show this, assume that \(\chi = (\alpha + \sqrt {\beta })/\gamma \) is a quadratic irrational number. Set \(\alpha = -\hat {b} \) and \(\gamma = 2 \hat {a} \) which implies that \(\hat {a} = 1/(2 \gamma )\) and \(\hat {b} = -\alpha / \gamma \). Equating

$$\displaystyle \begin{aligned} \beta = \hat{b}^2 - 4 \hat{a} \hat{c} = \frac{\alpha^2 - 2 \gamma \hat{c}}{\gamma^2} \end{aligned}$$

and solving yields \(\hat {c} = (\alpha ^2 - \beta \gamma ^2)/(2 \gamma )\).

Solutions to quadratics are not altered by multiplying their coefficients by a non-zero constant. Hence we can multiply \(\hat {a}\), \(\hat {b}\), and \(\hat {c}\) by 2γ leading to integer coefficients: a = 1, b = −2α, and c = α 2 − βγ 2. The resultant discriminant is not square since β is not square:

$$\displaystyle \begin{aligned} \sqrt{{b}^2 - 4 {a} {c}} = \sqrt{4 \gamma^2 \beta } = 2 \gamma \sqrt{\beta} \end{aligned}$$

By construction then χ satisfies the integer quadratic ax 2 + bx + c = 0. Clearly the conjugate quadratic irrational number, given by \(\chi ^\prime = (\alpha - \sqrt {\beta })/\gamma \), also satisfies this integer quadratic.

We note here that conjugates have algebraic properties that are best expressed by a set of identities

$$\displaystyle \begin{aligned} (\lambda \pm \nu)^\prime = \lambda^\prime \pm \nu^\prime \end{aligned}$$
$$\displaystyle \begin{aligned} (\lambda \nu)^\prime = \lambda^\prime \ \nu^\prime \end{aligned}$$
$$\displaystyle \begin{aligned} \left ( \frac{\lambda}{\nu} \right ) ^\prime = \frac{\lambda^\prime}{ \nu^\prime} \end{aligned}$$
$$\displaystyle \begin{aligned} \left ( \lambda^\prime \right ) ^\prime = \lambda \end{aligned}$$

Consider the set of numbers generated by varying α and γ of

$$\displaystyle \begin{aligned} \chi = \frac{\alpha + \sqrt{\beta}}{\gamma} \end{aligned} $$
(10.29)

and its conjugate

$$\displaystyle \begin{aligned} \chi^\prime = \frac{\alpha - \sqrt{\beta}}{\gamma} \end{aligned} $$
(10.30)

over all integer values while keeping β constant. If β is non-square and α and γ are integer with γ > 0, then this generates an infinite set of quadratic irrational numbers. Such a group of quadratic irrational numbers inherit their irrationality from the same source—their common \(\sqrt {\beta }\) term.

Restricting α and γ so that χ > 1 and − 1 < χ  < 0 creates a finite set of quadratic irrational numbers which are termed reduced quadratic surds. To derive bounds on α and γ that satisfy these inequalities, observe that χ > 1 and χ  > −1 imply that χ + χ  > 0. Thus 2αγ > 0 which implies that α > 0. Since χ  < 0, it must be the case that \(\alpha - \sqrt {\beta } < 0\). Collecting these inequalities establishes bounds on α:

$$\displaystyle \begin{aligned} 0 < \alpha < \sqrt{\beta} \end{aligned} $$
(10.31)

To address bounds on γ, note that χ > 1 implies that \(\alpha + \sqrt {\beta } > \gamma \). From χ  > −1 it follows that \(\alpha - \sqrt {\beta } > -\gamma \) or that \(\gamma > \sqrt {\beta } - \alpha \). Collecting these inequalities produces the following bounds:

$$\displaystyle \begin{aligned} \sqrt{\beta} - \alpha < \gamma < \alpha + \sqrt{\beta} \end{aligned} $$
(10.32)

As an example, consider the following table that gives the set of six reduced quadratic surds, along with their associated integer quadratic equations, that inherit their irrationality from \(\sqrt {7}\)

α

γ

Integer Quadratic Equation

Reduced Quadratic Surds

1

2

4x 2 − 4x − 6

\(\{ (1 + \sqrt {7})/2, \ (1 - \sqrt {7})/2 \}\)

1

3

9x 2 − 6x − 6

\(\{ (1 + \sqrt {7})/3, \ (1 - \sqrt {7})/3 \}\)

2

1

x 2 − 4x − 3

\(\{ 2 + \sqrt {7}, \ 2 - \sqrt {7}\}\)

2

2

4x 2 − 8x − 3

\(\{ (2 + \sqrt {7})/2, \ (2 - \sqrt {7})/2 \}\)

2

3

9x 2 − 12x − 3

\(\{ (2 + \sqrt {7})/3, \ (2 - \sqrt {7})/3 \}\)

2

4

16x 2 − 16x − 3

\(\{ (2 + \sqrt {7})/4, \ (2 - \sqrt {7})/4 \}\)

The key step in generating a continued fraction expansion is equation (10.24) which is expressed recursively with equations (10.25) and (10.26). To analyze the operation (10.24) with less awkward notion, let e = ⌊x⌋ and f = 1∕r(x) and thus

$$\displaystyle \begin{aligned} x = e + \frac{1}{f} \end{aligned} $$
(10.33)

Assume that x is a reduced quadratic surd. Then we claim that f is also a reduced quadratic surd with the same square root value as x. To establish this, let \(x = (\alpha + \sqrt {\beta })/\gamma \) and assume the associated integer quadratic equation is given by ax 2 + bx + c = 0 and hence α = −b, γ = 2a and β = b 2 − 4ac. Clearly e + 1∕f satisfies this integer quadratic equation so that

$$\displaystyle \begin{aligned} a \left (e + \frac{1}{f} \right )^2 + b \left (e + \frac{1}{f} \right ) + c = 0 \end{aligned}$$

Straightforward algebra shows that

$$\displaystyle \begin{aligned} (a e^2 + b e + c) f^2 + (2 a e + b) f + a = 0 \end{aligned} $$
(10.34)

Hence f is the root of this integer quadratic which can be written by

$$\displaystyle \begin{aligned} f = (\hat{\alpha} + \sqrt{\beta})/\hat{\gamma} \end{aligned}$$

where \(\hat {\alpha } = -(2 a e + b)\) and \(\hat {\gamma } = 2 (a e^2 + b e + c)\). Note that the discriminant of (10.34) is given by

$$\displaystyle \begin{aligned} \sqrt{(2 a e + b)^2 - 4 a (2 a e + b)} = \sqrt{b^2 - 4 a c }= \sqrt{\beta} \end{aligned}$$

so that both x and f inherit their irrationality from \(\sqrt {\beta }\).

To show that f is a reduced quadratic surd, first note that 0 < 1∕f < 1 since, by definition, 1∕f = r(x). Thus f > 1. To form its conjugate, solve (10.33) for f

$$\displaystyle \begin{aligned} f = \frac{1}{x - e} \end{aligned}$$

We can use the identities for conjugates to write

$$\displaystyle \begin{aligned} f^\prime = \frac{1}{x^\prime - e} \end{aligned} $$
(10.35)

By assumption − 1 < x  < 0 and by definition e ≥ 1. Thus (10.35) implies that − 1 < f  < 0.

With this preliminary work behind us, we find ourselves at the doorway of an important result. Linking up to the recursive process (10.26), the previous discussion shows that if x is a reduced quadratic surd, then ψ 0 = 1∕r(x) and ψ i = 1∕r(ψ i−1) for i ≥ 1 are also reduced quadratic surds sharing the same square root as x. Since there are only a finite number of reduced quadratic surds with the same square root, this implies that there exists a value such that ψ  = ψ 0 for 1 ≤  < . But this also implies that ψ +1 = ψ 1 since ψ +1 = 1∕r(ψ ) = 1∕r(ψ 0) = ψ 1. Repeating this process shows that ψ +k = ψ k for all k ≥ 0. Hence the continued fraction is purely periodic with period length . This proves that quadratic irrational numbers that are reduced quadratic surds have continued fractions that are purely periodic. Thus, for this special case, we have established Lagrange’s theorem. Lagrange’s theorem, however, is more general since it proves that all quadratic irrational numbers have a repeating structure from some point onward, even if they start with a non-periodic preamble. We will address this issue later in the chapter after establishing a limit property of continued fraction expansions.

An example at this point might be illustrative. Consider \(\sqrt {19} = [4, \underline {2,1,3,1,2,8}]\) which is not a reduced quadratic surd since \(-1 \nless -\sqrt {19}\). Adding \(4 = \lfloor \sqrt {19} \rfloor \) to this, however, produces a reduced quadratic surd which has a purely periodic continued fraction expansion: \(4 + \sqrt {19} = [ \underline {8,2,1,3,1,2}]\). A simple calculation shows that there are 20 reduced quadratic surds that inherit their irrationality from \(\sqrt {19}\). Six of these cycle to create the purely periodic continued fraction expansion given in the table below.

Cycle of Reduced Quadratic Surds for the Continued Fraction of \(4 + \sqrt {19}\)

Period Number

1

2

3

4

5

6

Reduced Quadratic Surd

\(\frac {4 + \sqrt {19}}{1}\)

\(\frac {4 + \sqrt {19}}{3}\)

\(\frac {2 + \sqrt {19}}{5}\)

\(\frac {3 + \sqrt {19}}{2}\)

\(\frac {3 + \sqrt {19}}{5}\)

\(\frac {2 + \sqrt {19}}{3}\)

Continued Fraction Digit

8

2

1

3

1

2

One additional fact about convergents will be all that we need to explain the special structure of continued fractions for square roots of non-square integers. Consider the recursion for the numerator of a convergent (equation (10.17)): n i = b in i−1 + n i−2. This can be rewritten as

(10.36)

For i = 1 this equation shows that

and for i = 2 that

The general pattern corresponds to a reversal of the digits in the continued fraction expansion. A simple induction thus shows

(10.37)

Applying the same procedure for the denominator shows a similar reversal

(10.38)

(the difference between (10.37) and (10.38) is a result of the different initial values).

Suppose that \(x = (\alpha + \sqrt {\beta })/\gamma \) is a reduced quadratic surd so that its continued fraction expansion is given by \(x=[ \underline {b_0, \ldots , b_{k}}]\) and assume its convergents are denoted by n id i. Repeating equation (10.21) shows that

$$\displaystyle \begin{aligned} {d}_{k} {x}^2 - ({n}_{k} - {d}_{k-1} ) {x} - {n}_{k-1} = 0 \end{aligned} $$
(10.39)

Let y correspond to a reversal of the digits of x: \(y = [ \underline {b_{k} , \ldots , b_{0}}]\). From the previous discussion, y has convergents given by

$$\displaystyle \begin{aligned} \frac{n_k}{n_{k-1}} = [\underline{b_{k} , \ldots , b_{0}}] = \frac{\hat{n}_k}{\hat{d}_{k}} \end{aligned}$$

and

$$\displaystyle \begin{aligned} \frac{d_k}{d_{k-1}} = [\underline{b_{k} , \ldots , b_{1}}]= \frac{\hat{n}_{k-1}}{\hat{d}_{k-1}} \end{aligned}$$

where \(\hat {n}_{k-1} = d_k\), \(\hat {d}_{k-1} = d_{k-1}\), \(\hat {n}_k = n_k\), and \(\hat {d}_k = n_{k-1}\). This implies that y satisfies

$$\displaystyle \begin{aligned} {\hat{d}}_{k} {y}^2 - ({\hat{n}}_{k} - {\hat{d}}_{k-1} ) {y} - {\hat{n}}_{k-1} = 0 \end{aligned}$$

or, after making the above substitutions, that

$$\displaystyle \begin{aligned} n_{k-1} {y}^2 - ({ {n}}_{k} - { {d}}_{k-1} ) {y} - d_k = 0 \end{aligned} $$
(10.40)

Setting z = −1∕y in (10.40) reverses the ordering of the coefficients of this quadratic leading to

$$\displaystyle \begin{aligned} d_k {z}^2 - ({ {n}}_{k} - { {d}}_{k-1} ) {z} - n_{k-1}= 0 \end{aligned} $$
(10.41)

These manipulations show that (10.41) and (10.39) are identical equations and thus x and z correspond to the quadratic’s two solutions. Expressed in terms of the conjugate of x, this implies that z = x

$$\displaystyle \begin{aligned} x^\prime = \frac{\alpha - \sqrt{\beta}}{\gamma} = - \frac{1}{y} \end{aligned} $$
(10.42)

so that y = −1∕x . Thus the continued fraction of x and of y are reversals of each other.

This allows a characterization of the continued fraction expansion of \(\sqrt {n}\) for non-square n. Assume that \(\sqrt {n}= [c_1, c_2, \ldots ]\) and note that this is not a reduced quadratic surd since \(-\sqrt {n}< - 1\) and thus is not purely periodic. By construction, c 1 = ⌊n⌋ and also that \(c_1 + \sqrt {n}\) is a reduced quadratic surd and thus is purely periodic

$$\displaystyle \begin{aligned} x = c_1 + \sqrt{n} = [\underline{2 c_1, c_2, \ldots , c_{k-1}, c_k}] \end{aligned} $$
(10.43)

and in the previous paragraphs we showed that the continued fraction expansion for y = −1∕x is a reverse of that for x, hence

$$\displaystyle \begin{aligned} y = \frac{1}{ \sqrt{n} - c_1} = [\underline{c_k, c_{k-1}, \ldots , c_2, 2 c_1}] \end{aligned} $$
(10.44)

Equation (10.43) implies that the form for the \(\sqrt {n}\) is given by

$$\displaystyle \begin{aligned} \sqrt{n} = [ c_1, \underline{ c_2, \ldots , c_{k-1}, c_k, 2 c_1}] \end{aligned} $$
(10.45)

Thus \(\sqrt {n} - c_1 = [0, \underline { c_2, \ldots , c_k, 2 c_1}]\) and, from relationship (10.10), that

$$\displaystyle \begin{aligned} \frac{1}{\sqrt{n} - c_1} = [ \underline{ c_2, \ldots , c_k, 2 c_1}] \end{aligned} $$
(10.46)

Equations (10.44) and (10.46) represent the same continued fraction which implies that there is a palindromic relationship between the coefficients, c j = c k+2−j, k = 2, …, k. Collecting these results together shows that the form of the continued fraction expansion for \(\sqrt {n}\) is given by

$$\displaystyle \begin{aligned} \sqrt{n} = [ \lfloor n \rfloor , \underline{ c_2, c_3, \ldots , c_{3}, c_2, 2 \lfloor n \rfloor}] \end{aligned} $$
(10.47)

This form is exemplified in all of the previous tables of the continued fraction expansions of square roots of non-square integers.

10.3 Approximations Using Continued Fractions

The chapter up to this point has focused on the structure of continued fraction expansions for irrational numbers and in particular concentrated on quadratic irrational numbers that have lovely expansions. This is not to say that continued fractions are not useful, however, since they are frequently used in approximations. To develop the subject along these lines it suffices to continue the example that started this chapter, that of \(\sqrt {2}\). The beginning portion of its decimal expansion is given by

$$\displaystyle \begin{aligned} \sqrt{2} = 1.4142135623731 \ldots \end{aligned}$$

Consider a series of truncated continued fractions leading to a series of approximations. If these approximations improve as more terms are added, then the inequality

$$\displaystyle \begin{aligned} \left | \sqrt{2} - [1,\underbrace{2, \ldots , 2}_{n+1 \ {\mathrm{terms}}} ]\right | < \left | \sqrt{2} - [1,\underbrace{2, \ldots , 2}_{n \ {\mathrm{terms}}} ]\right | , \ \ n=1, \ldots \end{aligned} $$
(10.48)

should hold. For the \(\sqrt {2}\) example these convergents yield

$$\displaystyle \begin{aligned}{}[1,2] = 3/2, \ \ \ [1,2,2] = 7/5, \ \ \ [1,2,2,2] = 17/12 \end{aligned}$$

which produces the following errors to the sequence of approximations:

$$\displaystyle \begin{aligned} \left | \sqrt{2} - 3/2 \right | &= .085786 \ \ldots \ \ \ \left | \sqrt{2} - 7/5 \right | = .014213 \ldots \\ &\left | \sqrt{2} - 17/12 \right | = .002453 \ldots \end{aligned} $$

These first three terms corroborate the intuition that the absolute difference between the approximation and the actual result decreases as more convergents are included in the continued fraction. The following table depicts the values obtained from successive convergent approximations for \(\sqrt {2}\):

Continued Fraction Approximations of \(\sqrt {2}\)

Step

b i

n i

d i

 

\(\sqrt {2} - n_i/d_i\)

λ i

1

2

3

2

− 0.

\(0857864376269049 \ldots \)

2

2

2

7

5

0.

\(0142135623730952 \ldots \)

10

3

2

17

12

− 0.

\(0024531042935716 \ldots \)

60

4

2

41

29

0.

\(0004204589248193 \ldots \)

348

5

2

99

70

− 0.

\(0000721519126191 \ldots \)

2,030

6

2

239

169

0.

\(0000123789411425 \ldots \)

11,830

7

2

577

408

− 0.

\(0000021239014147 \ldots \)

68,952

8

2

1393

985

0.

\(0000003644035520 \ldots \)

401,880

9

2

3363

2378

− 0.

\(0000000625217744 \ldots \)

2,342,330

10

2

8119

5741

0.

\(0000000107270403 \ldots \)

13,652,098

Three salient features of this table pose questions which beg to be addressed. Firstly, notice the oscillation of the sign of the difference between the approximation and the exact result. Odd steps overestimate the true value where even steps underestimate it. Does a series of convergents always rotate between overshooting and undershooting the precise value?

Secondly, notice the quick convergence of the approximation to the precise value where odd steps decrease towards the true value and even steps increase towards it. Does this always occur, and if so, how can one characterize the convergence rate?

Thirdly, observe that the values of n i and d i in the above table are always relatively prime (they have no common divisors) and the denominator steadily increases. Is this always the case?

To begin addressing these questions, consider the difference between two convergents,

(10.49)

It is clear from the general recurrence equation for convergents that d i forms an integer sequence that increases with i. Thus the denominator of (10.53), given by d i−1d i, is positive and increasing. Focusing on the numerator, write

$$\displaystyle \begin{aligned} n_i d_{i-1} - n_{i-1} d_{i} &= (b_i n_{i-1} + n_{i-2}) d_{i-1} - n_{i-1} (b_i d_{i-1} + d_{i-2}) \\ &= b_i n_{i-1} d_{i-1} + n_{i-2} d_{i-1} - b_i n_{i-1} d_{i-1} - n_{i-1} d_{i-2} \\ &= n_{i-2} d_{i-1} - n_{i-1} d_{i-2} \\ &= - (n_{i-1} d_{i-2} - n_{i-2} d_{i-1}) \end{aligned} $$

Telescoping this relationship to the boundary n 0d −1 − n −1d 0 = −1 implies that

$$\displaystyle \begin{aligned} n_i d_{i-1} - n_{i-1} d_{i} = (-1)^{i+1} \end{aligned} $$
(10.50)

This shows that a linear combination of n i and d i equals ± 1 and answers the third question above since it implies that they must be co-prime.Footnote 5

Defining λ i = d i−1d i permits rewriting (10.49) as

(10.51)

This suggests telescoping the relationship to get the following equation:

Using this, and equations (10.17) and (10.51), yields a succinct representation of a continued fraction

(10.52)

A simple recursion provides a lower bound on the rate at which λ i increases. First note that the recursion d i = b id i−1 + d i−2 implies that d i grows at least as fast as the integers. Substituting this recursion, and using the initial values of d i, provides the following equation for λ i:

$$\displaystyle \begin{aligned} \lambda_i = \left \{ \begin{array}{cl} 0, & i=0 \\ &\\ b_i d_{i-1}^2 + \lambda_{i-1}, & i = 1, \ldots \end{array} \right. \end{aligned} $$
(10.53)

which easily yields

$$\displaystyle \begin{aligned} \lambda_i = \sum_{j=1}^i b_j d_{j-1}^2 \end{aligned} $$
(10.54)

This shows that λ i grows at least as fast as the sum of the squared integers.

Equation (10.51) answers one portion of the first question above: truncating a continued fraction expansion creates an approximation that oscillates around a central value. Such oscillations, however, might not be around α 0 = [b 0, …]. To address this issue, use (10.18) to write the difference between α 0 and the convergents at the i’th step as:

(10.55)

This now fully answers the first question: odd and even indexed convergents successively alternate around α 0.

This brings us to the second question which can now be answered: the series of even indexed convergents increase towards α 0 whereas odd indexed convergents decrease towards it. Both reach the same limit which implies that |α 0 − n id i| is a decreasing sequence as conjectured in equation (10.48). These results can be summarized by an infinite series of inequalities

$$\displaystyle \begin{aligned} \frac{n_0}{d_0} < \frac{n_2}{d_2} < \cdots < \alpha_0 < \cdots < \frac{n_3}{d_3} < \frac{n_1}{d_1} \end{aligned} $$
(10.56)

Thus, continued fraction approximations converge to α 0 as the number of terms of the truncated continued fraction increases without bound. Observe that the last column in the table on page 152 shows a dramatic increase in the size of λ i as i increases for the \(\sqrt {2}\) example. At the tenth step, for instance, the value λ 10 is more than 13 million and the approximation is accurate to 7 decimals.

The least that λ i can be at each step occurs when the values of b i are least which occurs in the case of the golden ratio where b i = 1 for all i. This implies that, for a given degree of accuracy, the golden ratio requires more steps in a continued fraction approximation than any other irrational number. In this sense it is the hardest irrational number to approximate. Said more picturesquely, the golden ratio is the most irrational number! It is instructive to compare the table of its approximations to that of \(\sqrt {2}\):

Continued Fraction Approximations of \(\phi = (1 +\sqrt {5})/2\)

Step

b i

n i

d i

 

ϕ − n id i

λ i

1

1

2

1

− 0.

381966011250105…

1

2

1

3

2

0.

\(118033988749895 \ldots \)

2

3

1

5

3

− 0.

\(0486326779167718 \ldots \)

6

4

1

8

5

0.

\(0180339887498948 \ldots \)

15

5

1

13

8

− 0.

\(0069660112501051 \ldots \)

40

6

1

21

13

0.

\(0026493733652794 \ldots \)

104

7

1

34

21

− 0.

\(00101363029772417 \ldots \)

273

8

1

55

34

0.

\(00038692992636546 \ldots \)

714

9

1

89

55

− 0.

\(000147829431923263 \ldots \)

1,870

10

1

144

89

0.

\(000056460660007307 \ldots \)

4,895

Notice that at the tenth step, instead of more than 13 million with 7 digit accuracy, the value of λ 10 is less than 5 thousand leading to an accuracy of only 4 decimals.

We have seen the pattern of numbers in this table before. From the above table it appears that n i = f i+2 and d i = f i+1. Thus, another delightful equation links the golden ratio with the Fibonacci sequence

$$\displaystyle \begin{aligned} \phi \approx \frac{n_i}{d_i} = \frac{f_{i+2}}{f_{i+1}} \end{aligned} $$
(10.57)

From the third property above, this also yields the immediate result that successive Fibonacci numbers are co-prime. The last column of numbers also reveal a hidden jewel since they correspond to the cumulative sum of squared Fibonacci numbers. This follows from the recurrence (10.53) and the relationship λ i = f i+1f i which leads to \(\lambda _i = f_1^2 + \cdots + f_{i}^2\) (see equation (5.17) on page 70).

All of these results suggest that continued fractions are clever and accurate approximations to irrational numbers. To further support this claim, return to the portion of the denominator of equation (10.55) given by α i+1d i + d i−1. By construction, b i+1 = ⌊α i+1⌋ and clearly α i+1 > 1. This implies that

$$\displaystyle \begin{aligned} d_{i+1} = b_{i+1} d_{i} + d_{i-1} < \alpha_{i+1} d_{i} + d_{i-1} \end{aligned}$$

Applying this to equation (10.55), with some minor simplifications, yields the following upper and lower bounds on the accuracy of a continued fraction approximation:

$$\displaystyle \begin{aligned} \left | d_i \alpha _ 0 - n_i \right | < \frac{1}{d_{i+1}} \end{aligned} $$
(10.58)

The form of equation (10.58) motivates a method to compare approximations. A rational approximation nd is said to be a best approximation if \(\left | d \alpha _ 0 - n \right | < \left | \hat {d} \alpha _ 0 - \hat {n } \right |\) for any \(\hat {n}/\hat {d}\) where \(n/d \ne \hat {n}/\hat {d}\) and \(\hat {d} \le d\). In this definition it is assumed that both nd and \(\hat {n}/\hat {d}\) are fractions that have been reduced to have no common factors.

10.3.1 Best Approximations

The previous results lead to a beautiful result: all best approximations are convergents from a continued fraction approximation. To prove this, first assume that \(\hat {d} = d_i\) for the i’th convergent and note that the triangle inequality implies that

$$\displaystyle \begin{aligned} \left | {\hat{n}} - {n_{i} }\right | \le \left | \hat{n} - {d_{i}} \alpha_0 \right | + \left | {d_{i}} \alpha_0 - {n_{i} }\right | \end{aligned} $$
(10.59)

The bound of (10.58), and the fact that \(\hat {n} \ne n_{i}\), implies that

$$\displaystyle \begin{aligned} \left | \hat{n} - n_{i} \right | - \left | d_i \alpha_0 - n_{i} \right | > 1 - \frac{1}{d_{i+1}} = \frac{d_{i+1}-1}{d_{i+1}} > \frac{1}{d_{i+1}} \end{aligned} $$
(10.60)

The triangle inequality (10.59) thus implies that

$$\displaystyle \begin{aligned} \frac{1}{d_{i+1}} < \left | \hat{n} - n_{i} \right | - \left | d_i \alpha_0 - n_{i} \right | \le \left | {d_{i}} \hat{n} - \alpha_0 \right | \end{aligned}$$

which, compared to (10.58), shows that \(\hat {n}/\hat {d}\) is not a best approximation.

Assume now that \(\hat {n}/\hat {d}\) is a best approximation where \(\hat {d}\) is not equal to the denominator of any convergent. Without loss of generality we will prove the case where \(\hat {n}/\hat {d} < \alpha _0\) (the case where \(\hat {n}/\hat {d} > \alpha _0\) is completely analogous). Select i to satisfy

$$\displaystyle \begin{aligned} \frac{n_{2i-2}}{d_{2i-2}} < \frac{\hat{n}}{\hat{d}} < \frac{n_{2i}}{d_{2i}} < \alpha_0 < \frac{n_{2i-1}}{d_{2i-1}} \end{aligned} $$
(10.61)

All variables are integers and thus the following inequalities are satisfied:

$$\displaystyle \begin{aligned} \hat{n} d_{2i-2} - n_{2i-2} \hat{d} \ \ge \ 1 \end{aligned} $$
(10.62)

and

$$\displaystyle \begin{aligned} n_{2i}\hat{d} - \hat{n} d_{2i} \ \ge \ 1 \end{aligned} $$
(10.63)

Equations (10.61) and (10.51) show that

$$\displaystyle \begin{aligned} \frac{\hat{n}}{\hat{d}} - \frac{n_{2i-2}}{d_{2i-2}} < \frac{n_{2i-1}}{d_{2i-1}} - \frac{n_{2i-2}}{d_{2i-2}} = \frac{1}{d_{2i-2} d_{2i-1}} \end{aligned} $$
(10.64)

and

$$\displaystyle \begin{aligned} \frac{n_{2i}}{d_{2i}} - \frac{\hat{n}}{\hat{d}} < \alpha_0 - \frac{\hat{n}}{\hat{d}} \end{aligned} $$
(10.65)

Equation (10.62) implies that

$$\displaystyle \begin{aligned} \frac{\hat{n}}{\hat{d}} - \frac{n_{2i-2}}{d_{2i-2}} = \frac{ \hat{n} d_{2i-2} - n_{2i-2} \hat{d}}{d_{2i-2} \hat{d}} \ge \frac{1}{d_{2i-2} \hat{d}} \end{aligned}$$

which, with inequality (10.64), implies that

$$\displaystyle \begin{aligned} \hat{d} < d_{2i-1} \end{aligned} $$
(10.66)

Equation (10.63) implies that

$$\displaystyle \begin{aligned} \frac{n_{2i}}{d_{2i}} - \frac{\hat{n}}{\hat{d}} = \frac{ n_{2i}\hat{d} - \hat{n} d_{2i}}{d_{2i} \hat{d}} \ge \frac{1}{d_{2i} \hat{d}} \end{aligned}$$

which, with inequality (10.65), implies that

$$\displaystyle \begin{aligned} \frac{1}{d_{2i}} < \hat{d} \alpha_0 - \hat{n} \end{aligned}$$

Additionally, equation (10.58) implies the following inequality

$$\displaystyle \begin{aligned} d_{2i-1} \alpha_0 - n_{2i-1} < \frac{1}{d_{2i}} \end{aligned}$$

These last two inequalities thus result in

$$\displaystyle \begin{aligned} d_{2i-1} \alpha_0 - n_{2i-1} < \hat{d} \alpha_0 - \hat{n} \end{aligned}$$

which, along with (10.66), contradicts the assumption that \(\hat {n}/ \hat {d}\) is a best approximation. The two cases above show that a best approximation cannot differ from a convergent from a continued fraction—a beautiful, and extremely useful, result.

10.4 Lagrange’s Theorem and Historical Review

Before tying up some of the loose ends, let’s step back in time and pay homage to some early mathematicians who somehow discovered the power of convergent approximations. The first few convergents that approximate π, for example, are given by 22/7, 333/106, and 355/113 = 3.141592. The last of these approximations, which is amazingly accurate to 6 decimals, was known to Tsu Ch’ung-Chih (429–500), a mathematician in the service of the Chinese emperor, Hsiao-wu. The same approximation was also known to Adriaan Anthonisz (1527–1607), a Dutch mathematician and surveyor. Six decimals of accuracy is achieved for the golden ratio at the 15’th convergent leading to the approximation ϕ ≈ 1, 597∕987. Similar accuracy is achieved for \(\sqrt {2}\) at the 8’th convergent with the approximation \(\sqrt {2} \approx 1{,}393/985\). The 7’th convergent for \(\sqrt {2}\) yields 5 decimals of accuracy, \(\sqrt {2} \approx 577/408\), and was known by Greek mathematicians of the fifth century B.C. as well as by Indian mathematicians of the third or fourth century B.C.

The theorem of Lagrange was left hanging in midair. Recall that the analysis only proved the special case that quadratic irrational numbers that are reduced quadratic surds have purely periodic continued fractions. The theorem states that all quadratic irrationals eventually have periodic expansions. To complete the proof, first form the conjugate of equation (10.18)

This implies that

Previous work in the chapter shows that convergents n i−1d i−1 and n id i converge to α 0 as i increases without bound and that 0 < d i−1d i < 1 for all i. Thus, for some value i , the value of \( ({\alpha _0^\prime - n_{i^\star -1}/d_{i^\star -1}}) / ({\alpha _0^\prime - {n_{i^\star }}/{d_{i^\star }}})\) is less than 1. It follows that this observation is also valid for all values k ≥ i which implies that the value of \(\alpha _{k+1}^\prime \) from i onward falls between − 1 and 0. The fact that α k+1 > 1 for all k shows that after i , α k+1 is a reduced quadratic surd. The conclusion is thus that continued fraction onward from convergent i is periodic. This completes the proof of Lagrange’s theorem.