You are on page 1of 16

1 Continued Fractions

To start off the course, we consider a generalization of the Euclidean Algorithm which has ancient
historical roots and yet still has relevance and applications today.

1.1 Continued Fraction Representations of Rational Numbers


61
We start with a simple example, messing with the fraction 14 . First write the fraction as an integer
plus a fraction less than 1:
61 5
= 4+
14 14
Now we do something strange; flip the second fraction upside down and repeat:

61 5 1 1 14
= 4+ = 4 + 14 = 4 + 4
(take out integer part 2 of 5)
14 14 5 2+ 5
1 1 4
= 4+ = 4+ (flip 5 and take out integer part 1)
1 1
2+ 5
2+
4
1
1+
4
We stop here because the last fraction 14 is the reciprocal of an integer. We call this representation of
61
14 a continued fraction. To save writing the whole thing out, we simply use the notation

61
= [4; 2, 1, 4]
14
Now we need the promised tie-in with the Euclidean Algorithm. Suppose we applied the Algorithm
to find gcd(61, 14):
61 = 4 · 14 + 5
14 = 2 · 5 + 4
5 = 1·4+1
4 = 4·1
The relationship should be obvious! At each stage we are applying the Division Algorithm: if a >
b > 0 then there exist unique integers, the quotient q and remainder r which satisfy
a = qb + r and 0≤r<b
The remainders in the Euclidean Algorithm are underlined. However, it is the sequence of quotients
61
4, 2, 1, 4 that appears in the continued fraction representation of 14 .

Here is another example:

105 27 1 1 1 1
= 2+ = 2 + 39 = 2 + = 2+ = 2+ = [2; 1, 2, 4]
39 39 27 1 + 12
27
1 1
1+ 27
1+
12
1
2+
4

1
Sure enough, if we apply the Euclidean Algorithm,

105 = 2 · 39 + 27
39 = 1 · 27 + 12
27 = 2 · 12 + 3
12 = 4 · 3

we see the same sequence 2,1,2,4 of quotients!

What’s the Point? Why would any sensible person want to write an already simple expression in
such a convoluted manner? One answer is that by truncating a continued fraction we can produce
approximations to our original fraction. For example:

[4] = 4
1 9
[4; 2] = 4 + = = 4.5
2 2
1 1 13
[4; 2, 1] = 4 + 1
=4 = = 4.333 . . .
2+ 1 3 3
1 1 61
[4; 2, 1, 4] = 4 + = 4+ = = 4.35714 . . .
1 1 14
2+ 5
2+
4
1
1+
4
Observe how these approximations alternate below and above the final answer. Similarly, for our
other example,

[2] = 2
1
[2; 1] = 2 + =3
1
1 2 8
[2; 1, 2] = 2 + 1
= 2 = = 2.333 . . .
1+ 2 3 3
1 105
[2; 1, 2, 4] = 2 + = = 2.6923 . . .
1 39
1+
1
2+
4
Again, the approximations alternate below and above the final answer. We shall later that, in a certain
precise sense, 13 61
3 is the best rational approximation to 14 whose denominator is less than 14. Finding
rational approximations with small denominators was crucial in the days before calculators!

We are in fact in a position to prove that the coefficients for a continued fraction are always the quo-
tients from the Euclidean Algorithm. Have a go yourself before seeing the proof in a few pages.
Before seeing more fractions and defining things more directly, we make a historical digression to
consider one of the oldest known discussions of irrationality, for it is in the realm of irrational num-
bers that continued fractions reall show their worth.

2
1.2 Incommensurability and the Ancient Greeks: non-examinable
The ancient Greek mathematician Theaetetus (417–369 BCE) developed a notion of irrationality which
formed the basis of the longest and most difficult book (Book X) of Euclid’s Elements (c.300 BCE). The
purpose of Book X was the classification of incommensurables, or to us irrationals. It needs to be un-
derstood that the Greeks spoke only of whole numbers and of lengths which were in whole number
5
ratios to each other. Thus 17:5 might represent two rods, the second of which was 17 the length of the
first. The term rational was not used, instead Theaetetus considered whether two lengths were com-
mensurable, meaning that the two were integer multiples of some common sub-length. In the above
case one could produce a third small rod, 17 of which would measure the first rod and 5 the second.
Strictly speaking, lengths `1 and `2 are commensurable if and only if there exists some sub-length
m and positive integers a, b such that `1 = am and `2 = bm. Otherwise said, the lengths are in
proportion

`1 : `2 = a : b

In modern times, we are happy equating the concepts of length and number1 and we’d simply say
that the ratio ``21 is a rational number. The question Theaetetus considered was twofold:

1. If two lengths are commensurable, how do we find the common sub-length m?

2. If two lengths are incommensurable, how do we prove it? That is, how do we show that no such
common sub-length m exists?

His answer to the first question is essentially the Euclidean Algorithm, for if `1 and `2 are integers,
then the common sub-length is precisely the greatest common divisor of `1 and `2 . Here is an example
with two initial lengths `1 and `2 :

`1
`2 `1 = 3`2 + `3
`3 `2 = 2`3 + `4
`4 `3 = 2`4
`1 = 17`4
`2 = 5`4
In this case, `4 is the common sub-length. By choosing units so that `4 = 1 we see that we’ve applied
the Euclidean Algorithm to calculate gcd(17, 5) = 1.
The point of this digression is that the Euclidean Algorithm works perfectly well when applied to
lengths, not just integers. Indeed, to the Greeks, the Division Algorithm (the main ingredient in the
Euclidean Algorithm) may be stated as follows; if `1 > `2 are rods of positive length, there exists a
unique integer q ≥ 1 and a length r which satisfy two properties:

1. `1 may be measured by q copies of `2 plus a single copy of r, i.e. `1 = q`2 + r.

2. r is shorter than `2 , i.e. 0 ≤ r < `2 .


1 We assume that there is a base length of 1 somewhere with respect to which all other lengths may be compared. This
is precisely what choosing units does for us. The Greeks had a philosophical difficulty with this idea: how do you know
that all lengths may be measured with respect to a fixed length? In the absence of irrational numbers, they can’t.

3
We can now give Theaetetus’ definition of commensurability.
Definition 1.1. Lengths `1 , `2 are commensurable if and only the Euclidean Algorithm terminates. The
common sub-length is then the last length in the sequence. The lengths `1 , `2 are incommensurable if
and only if the Algorithm never terminates.
In modern language, `1 , `2 are commensurable if and only if ``21 ∈ Q.
We can now state a simple Theorem in this language.
Theorem 1.2. Suppose that lengths `, m are in the golden ratio:2 that is ` + m : ` = ` : m. Then ` and m are
incommensurable. Otherwise said, the golden ratio is irrational.
Proof. Clearly m` = `+`m > 1 since m is a positive length. Now suppose that ` ≥ 2m: we obtain a
contradiction
` `+m 2` + 2m 3` 3
2≤ = = ≤ = (∗)
m ` 2` 2` 2
It follows that the first quotient in the algorithm is 1 and that the first line reads
` = 1 · m + (` − m)
Now continue;
`−m ` m
= −1 = (†)
m m `
says that the ratio `−mm is also golden! The second line of the algorithm will have quotient 1, as will
all subsequent lines: the algorithm therefore continues ad infinitum, with an infinite sequence of
quotients equal to 1. We conclude that ` and m are incommensurable.

You’ve probably seen the famous adjoining picture: each


step of the algorithm can be visualized as deleting a square
from a golden rectangle, leaving a smaller (similar) golden
rectangle.
`
The Greek method of working geometrically makes things
very difficult for us algebra-hungry modernites. Indeed it is
very hard to resist writing

` m

` −1 2 5+1
ϕ= =⇒ ϕ = 1 + ϕ =⇒ ϕ − ϕ − 1 = 0 =⇒ ϕ =
m 2

The Greeks, of course, had no notion of 5, so the above was essentially how they proceeded: fun!
2 For clarity, we write in fractions so that the golden ratio reads `+m
= m` . This would have made no sense to the Greeks,
`
since length and number were distinct concepts. To be more historically accurate, we should write equation (∗) as
2 : 1 ≤ ` : m = ` + m : ` = 2` + 2m : 2` ≤ 3` : 2` = 3 : 2
and (†) using subtraction of ratios
(
`+m : ` = ` : m
=⇒ m : ` = ` − m : m
`:`=m:m
The Greeks did not have algebra, but this method of computing with ratios was understood and used in the Elements.

4
1.3 Continued Fractions and Irrational Numbers
Motivated by Theaetetus, we try a continued fraction approach for irrational numbers. If the golden
ratio produces an infinite sequence of quotients equal to 1, is it reasonable to write the following?

5+1 1
ϕ= = [1; 1, 1, 1, . . .] = 1 +
2 1
1+
1
1+
1+···
The answer is yes, though to prove everything will take some time: the critical difficulty is that the
ellipses · · · are making a claim about the convergence of some sequence. Defining the correct sequence
and proving that it converges to ϕ is the challenge.
Before all that, we define the concept of a continued fraction in a manner that’s more user-friendly
for dealing with irrational numbers.
Definition 1.3. Suppose that x is a real number. Define a pair of sequences (ck ), ( Rk ) inductively
c1 : = b x c R1 : = x − c1
1 1
 
cn := Rn := − cn
R n −1 R n −1
The notation b x c is the floor of x: the greatest integer less than or equal to x. If any term Rn is zero,
then the sequences terminate. The continued fraction representation of x is written [c1 ; c2 , c3 , . . .].

Examples
1. It is worth revisiting our first example in this language.
61 61 5
 
c1 = =4 R1 = −4 =
14 14 14
14 14 4
 
c2 = =2 R2 = −2 =
5 5 5
5 5 1
 
c3 = =1 R3 = − 1 =
4 4 4
c4 = b4c = 4 R4 = 4 − 4 = 0
Clearly this produces the same sequence and continued fraction representation we saw earlier.
2. Now we √
try this for the golden ratio. √
If ϕ = 2 , then 1 < ϕ < 2, whence c1 = 1 and R1 = 52−1 . Then
5+1

 $√ % √
2 5+1 5−1

c2 = √ = = 1 =⇒ R2 =
5−1 2 2

Both sequences have already begun to repeat: we therefore obtain the continued fraction
[1; 1, 1, 1, 1, 1, 1, . . .]
as desired.

5

3. Find the continued fraction expansion of 13.
√ √
Since 3 < 13 < 4 we have c1 = 3 and R1 = 13 − 3. Thus
√ √
1 1 13 + 3 13 − 1
=√ = = 1+ =⇒ c2 = 1
R1 13 − 3 4 4

Rinse and repeat:

n 1 2 3 4 5 6 7 8
cn 3 1 1 1 1 6 1 1
√ √
13−1

13−2

13−1

13−3
√ √
13−1

13−2
Rn 13 − 3 4 3 3 4 13 − 3 4 3

Since the sequences ( Rn ), (cn ) have started√to repeat, it follows that they will continue to do so.
Thus the continued fraction expansion of 13 is the repeating sequence

[3; 1, 1, 1, 1, 6, 1, 1, 1, 1, 6, 1, 1, 1, 1, 6, . . .]

4. The first few terms of the continued fraction expansion for π can be found similarly, though
you’ll need a calculator! Unlike the two previous examples, there will be no on-going pattern
to find.3

c1 = bπ c = 3 =⇒ R1 = π − 3
1 1 22 − 7π
 
c2 = = 7 =⇒ R2 = −7 =
π−3 π−3 π−3
π−3 π−3 106π − 333
 
c3 = = 15 =⇒ R3 = − 15 =
22 − 7π 22 − 7π 22 − 7π
22 − 7π
 
c4 = = 1 =⇒ R4 = · · ·
106π − 333

We obtain the continued fraction [3; 7, 15, 1, . . .].

These examples suggest the following:

Theorem 1.4. 1. A real number has a finite continued fraction representation if and only if it is rational.

2. If x = ba is rational, then it equals its continued fraction representation, which moreover consists of the
sequence of quotients from the Euclidean Algorithm applied to the pair ( a, b).

3. If x is any real number, its continued fraction representation is the sequence of quotients found by apply-
ing the Euclidean Algorithm (à la Theaetetus) to the pair ( x, 1).

Before proving this, it is worth noting a couple of caveats. If c1 = x, then x is an integer and its (very
boring) continued fraction is itself. The first quotient c1 in a continued fraction is negative if and only
if x is negative: all the other quotients must be positive.
3 The beady-eyed should notice the 22 and 7 that appear prominently in the calculation. . .

6
a
Proof. Suppose first that x = b ∈ Q+ . Write the Euclidean Algorithm for finding gcd( a, b) = rn−1 :
a = c1 b + r1 0 ≤ r1 < b
b = c2 r1 + r2 0 ≤ r2 < r1
r1 = c3 r2 + r3 0 ≤ r3 < r2
..
.
r n −3 = c n −1 r n −2 + r n −1 0 ≤ r n −1 < r n −2
r n −2 = c n r n −1
In each case we have
r r r
 
c k = k −2 − k = k −2
r k −1 r k −1 r k −1
since 0 ≤ rk < rk−1 and ck is an integer. Now compute:4
a r 1 1 1 1
= c1 + 1 = c1 + b = c1 + r2 = c1 + = c1 +
b b r
c2 + r1 1 1
1 c2 + r1 c2 + r3
r2 c3 + r2
1 1
= c1 + = c1 + = [ c1 ; c2 , . . . , c n ]
1 1
c2 + r n −2 c2 +
···+ r n −1 1
c3 +
· · · + cn
a
Thus any positive rational number b has a finite continued fraction expansion whose coefficients are
precisely the quotients in the Euclidean Algorithm. Conversely, if a continued fraction terminates,
then it is certainly rational. We have therefore proved parts 1 and 2.
For part 3, x − b x c is less than 1, and so
x = b x c · 1 + ( x − b x c) = c1 · 1 + R1
is precisely the first line of Theaetetus’ Algorithm applied to the pair ( x, 1). The next line is then
1 1
     
1= · R1 + 1 − R1 = c2 · R1 + R1 R2
R1 R1
 j k
with positive remainder R1 R2 = R1 R11 − R11 < R1 . And the third:
1 1
     
R1 = · R1 R2 + R1 1 − R2 = c3 · R1 R2 + R1 R2 R3
R2 R2
 j k
with positive remainder R1 R2 R3 = R1 R2 R12 − R12 < R1 R2 . Without being too formal (prove by
induction if you like), we see that the kth line has the form
R 1 · · · R k −2 = c k · R 1 · · · R k −1 + R 1 · · · R k
1 1 1
    
= · R 1 · · · R k −1 + R 1 · · · R k −1 −
R k −1 R k −1 R k −1
This proves 3: indeed the kth remainder in the Algorithm is the product R1 · · · Rk .
4 More r k −2 1
formally, let a = r−1 , b = r0 and observe that r k −1 = ck + rk−1 /rk and argue by induction.

7
1.4 Convergents of Continued Fractions
We’ve already seen that a continued fraction representation of a rational number is equal to that
number. To see that the same is true for irrational numbers, we need a notion of convergence.

Definition 1.5. Given the sequence of quotients (cn ), define new sequences ( pn ), (qn ) via

p0 = 1 p1 = c1 p n = c n p n −1 + p n −2
q0 = 0 q1 = 1 q n = c n q n −1 + q n −2
pn
The ratio qn is termed the nth convergent of the continued fraction [c1 ; c2 , c3 , . . .].

61
Example For α = 14 , the sequences are

n 0 1 2 3 4
cn 4 2 1 4
pn 1 4 9 13 61
qn 0 1 2 3 14

If you’re struggling to remember the formulæ, look at the pattern in the table: the three red numbers
combine to produce the blue:

9 = 2·4+1

Observe that the sequence of convergents

pn 9 13 61
   
= 4, , ,
qn 2 3 14

is the sequence of approximations we obtained on page 2 by truncating the continued fraction.

The same thing can be seen with any of our other examples: indeed we have the following result.
pn
Theorem 1.6. = [ c1 ; . . . , c n ]
qn
The Theorem can be broken into a two-part lemma.

Lemma 1.7. Let c1 , . . . , cn be integers such that the continued fraction [c1 ; . . . , cn ] exists.5 We can describe
the continued fraction in terms of a matrix multiplication.

c1 1 c2 1 c3 1 cn 1 A B
       
1. ··· = =⇒ [c1 ; . . . , cn ] = CA .
1 0 1 0 1 0 1 0 C D

A B p n p n −1
   
2. In terms of the sequences ( pn ) and (qn ), we have = .
C D q n q n −1
5 Strictly
c2 , . . . , cn are positive integers, and cn ≥ 2. Part 1 holds for any real numbers provided we never divide by
zero: something like [2; 1, −1] = 2 + 1 1 clearly cannot be allowed!
1 + −1

8
Proof. We prove part 1 by induction; part 2 is left as an exercise.
c1 1 A B
   
c1 A
For the base case, observe that [c1 ] = c1 = 1 = C when = .
1 0 C D
Now fix n and assume that any continued fraction of length n − 1 satisfies the condition

A c2 1 c3 1 c 1 A B
      
[ c2 ; . . . , c n ] = where ··· n =
C 1 0 1 0 1 0 C D

Then
1 C c A+C
[ c1 ; c2 , . . . , c n ] = c1 + = c1 + = 1
[ c2 ; . . . , c n ] A A

However
c1 1 A B c A + C c1 B + D
    
= 1
1 0 C D A B

By induction, part 1 is proved.

We now want to see that the convergents of an irrational number x really converge to x. This is a
somewhat tedious piece of elementary analysis: it starts by taking determinants of the statement of
Lemma 1.7: since each matrix on the left has determinant −1, we have

(−1)n = pn qn−1 − pn−1 qn

In particular, gcd( pn , qn ) = 1 =⇒ the convergents are fractions in lowest terms. Moreover,

pn p (−1)n
− n −1 =
qn q n −1 q n q n −1

We therefore see that


pn (−1)n p (−1)n (−1)n−1 p n −2
[ c1 ; c2 , . . . , c n ] = = + n −1 = + + = ···
qn q n q n −1 q n −1 q n q n −1 q n −1 q n −2 q n −2
(−1)n (−1)n−1 1 p
= + +···+ + 1
q n q n −1 q n −1 q n −2 q2 q1 q1
n k
(−1)
= c1 + ∑
q q
k =2 k k −1

Since qk is an increasing sequence (qk+1 = ck+1 qk + qk−1 ≥ qk with equality only if k= 1 and c2 = 1)
p
it follows that the sequence ( qn q1n−1 ) decreases to zero. The sequence of convergents qnn is therefore
the nth partial sum of a convergent alternating series. By the standard theory of such series6 we see
that the limit L satisfies
p1 p3 p5 p6 p4 p2 pn 1

< ··· < L < ··· < and L− <

< < < <
q1 q3 q5 q6 q4 q2 qn q n q n +1
6 I.e. the proof of the alternating series test.

9
The sequence of convergents is indeed convergent! It remains to see that its limit is x. For this, first
observe that for all n ∈ N
1
x = c1 +
1
c2 +
1
···+
cn + Rn
In particular, for the first three convergents,
p1
x = c1 + R1 > c1 = [ c1 ] =
q1
1 1 p2
x = c1 + < c1 + = [ c1 ; c2 ] =
c2 + R2 c2 q2
1 1 p3
x = c1 + > c1 + = [ c1 ; c2 , c3 ] =
1 1 q3
c2 + c2 +
c3 + R3 c3
The pattern is obvious and can easily be proved; the convergents are alternately smaller (if n is odd)
or larger (if n is even) than x. We therefore see that
p1 p3 p5 p7 p8 p6 p p2
< < < < ··· < x < ··· < < < 4 <
q1 q3 q5 q7 q8 q6 q4 q2
and we’ve (finally!) proved the first two parts of the following.
Theorem 1.8. Suppose that x is irrational and has continued fraction representation [c1 ; c2 , c3 , . . .].
pn
1. x is the limit of the sequence of convergents qn = [ c1 ; c2 , . . . , c n ]:

pn (−1)n
x = lim = c1 + ∑
n→∞ qn n =2 q n q n −1

2. The nth convergent satisfies

x − pn < 1


qn q n q n +1

3. Each convergent is closer to x than the previous:

x − p n +1 < x − p n


q n +1 qn

Direct proofs of the latter parts of the Theorem are exercises. Indeed with the slight modification (in
the second part) of converting < to ≤, they are true even when x is rational. The latter parts were
very useful in the days before calculators, where they could be used to guarantee a particular level
of accuracy in an approximation. Given the Theorem, it is now legitimate for us to write
x = [ c1 ; c2 , c3 , . . . ]
for any real number x, where it is understood that this means the limit of the sequence of convergents
when x is irrational. More theoretically, if you recall the discussion in analysis where the real numbers
may be defined as the set of limits of sequences of rational numbers, this procedure produces a
concrete example of a sequence which converges to a given irrational number.

10

Examples With x = 13 = 3.605555 to 5dp, we have
n 0 1 2 3 4 5 6 7 8 9 10
cn 3 1 1 1 1 6 1 1 1 1
pn 1 3 4 7 11 18 119 137 256 393 649
qn 0 1 1 2 3 5 33 38 71 109 180
pn
qn 3 4 3.5 3.66667 3.6 3.60606 3.60526 3.60563 3.60550 3.60556

With π we obtain [3, 7, 15, 1, 292, 1, . . .] whence, to 8dp we have


n 0 1 2 3 4 5 6
cn 3 7 15 1 292 1
pn 1 3 22 333 355 103993 104348
qn 0 1 7 106 113 33102 33215
pn
qn 3 3.14285714 3.14150943 3.14159292 3.14159265 3.14159265

According to part 2 of the above Theorem,

π − 22 < 1 1

= 0.0013477 . . .

=
7 7 · 106 742
In fact, π − 22
7 = 0.0012644 . . ., so the accuracy estimate is very good. Similarly

π − 333 < 1 1

= 0.0000834 . . .

=
106 106 · 113 11978
It is worth noting that the somewhat larger values for the quotients in the sequence (cn ) make the
denominators
√ of the convergents for π increase faster and produce better approximations than those
for 13. In this sense, the golden ratio ϕ = [1, 1, 1, 1, 1, . . .] has a very slowly converging sequence of
convergents.

1.5 Periodicity of Continued Fractions


You might have spotted the following pattern: irrational numbers containing a square root eventually
have periodic continued fraction expressions.

Example Suppose that x = [2; 1, 4, 1, 4, 1, 4, . . .]. The eventual periodic terms can be written as
1
y = [1; 4, 1, 4, . . .] = [1; 4, y] = 1 +
1
4+
y
Some simple algebra turns this into a quadratic equation for y:

2 1+ 2
4y − 4y − 1 = 0 =⇒ y = (y is clearly positive)
2
from which
1 2 √
x = 2+ = 2+ √ =2 2
y 1+ 2
Indeed there is a general result here:

11
Theorem 1.9. A continued fraction is ultimately periodic if and only if it is the continued fraction of an

irrational number of the form x = α + β γ where α, β, γ are rational.
Sketch Proof. We only prove the =⇒ direction, attributable to Euler. The converse, courtesy of La-
grange, is not much more difficuly, but takes a lot longer to write.
If x has a continued fraction which is eventually periodic with period n, then

x = [ d1 ; d2 , d3 , . . . , dr , c1 , c2 , . . . , c n , c1 , c2 , . . . , c n , . . . ]

Abusing notation slightly, we may then write α as a finite continued fraction

x = [ d1 ; d2 , d3 , . . . , dr , y ], where y = [ c1 ; c2 , . . . , c n , y ]

By a straightforward generalization of Lemma 1.7 (see homework), we see that


p n y + p n −1
y = [ c1 ; c2 , . . . , c n , y ] = =⇒ qn y2 + (qn−1 − pn )y − pn−1 = 0
q n y + q n −1
pk
where are the convergents for y. Since y is irrational and satisfies a quadratic equation with rational
qk
√ √
coefficients, it follows that it has the form7 y = δ + e γ ∈ Q( γ). Since x may be computed from y
√ √
using only operations keeping us in the field Q( γ), it follows that x also lies in Q( γ).

1.6 Best/Diophantine Approximations of Irrational Numbers


The question of finding good rational approximations to irrational numbers is very old. The approx-
imation π ≈ 22 7 has been known for thousands of years: we’ve now seen that it arises naturally from
the consideration of continued fractions. In this section, we make two definitions of what it means
to be a best rational approximation of an irrational number x, and see that the convergents of the
continued fraction representation of x in fact yield these approximations.
Definition 1.10. Let p, q ∈ N, and let x be a positive irrational number.
p
1. We say that is a best approximation to x of the first kind if,
q

a p p a

∀ a, b ∈ N such that 6= and b ≤ q we have x − < x −

b q q b

p
Of all fractions with denominators less than or equal to q, the fraction q is closest to x.
p
2. We say that q is a best approximation to x of the second kind if,
a p
∀ a, b ∈ N such that 6= and b ≤ q we have |qx − p| < |bx − a|
b q
The distance of qx to the nearest integer is smaller than that of all other bx when b < q.
Note that the definitions only have strict inequalities because x is irrational. If x has two distinct
rational approximations of the same accuracy (of either type), then it easy to see that x ∈ Q. In a
p
given situation, it is therefore often enough to prove that x − q ≤ x − ba , etc.

7 Q( √ γ ) √
= {δ + e γ : δ, e ∈ Q} is an extension field of the rational numbers; it is closed under addition and multiplica-
tion, and all non-zero elements have multiplicative inverses.

12
Example Consider π = 3.14159 . . .. We can produce a table indexed by denominators q of the
p
rational number q closest to π and whether these are best approximations:

p p

q closest − first kind? qπ second kind?

q π q
3
1 1 0.14159 . . . Y 3 + 0.14159 . . . Y
6
2 2 =3 n/a 6 + 0.28318 . . . N
9
3 3 =3 n/a 9 + 0.42477 . . . N
13
4 4 = 3.25 0.10840 . . . Y 13 − 0.43362 . . . N
16
5 5 = 3.2 0.05840 . . . Y 16 − 0.29203 . . . N
19
6 6 = 3.1666 . . . 0.02507 . . . Y 19 − 0.15044 . . . N
22
7 7 = 3.1428 . . . 0.00126 . . . Y 22 − 0.00885 . . . Y
25
8 8 = 3.125 0.01659 . . . N 25 + 0.13274 . . . N
28
9 9 = 3.1111 . . . 0.03048 . . . N 28 + 0.27433 . . . N
31
10 10 = 3.1 0.04159 . . . N 31 + 0.41592 . . . N

Note:
p p

• is a best approximation of the first kind ⇐⇒ π − q is smaller than all entries above it.

q

p
• q is a best approximation of the second kind ⇐⇒ the non-integer part of qπ is smaller than
all entries above it.

It takes a while to find the next best approximation of the second kind: you shouldn’t be surprised to
discover that it is the next convergent of π:

333
= π − 0.0000832 . . . 106π − 333 = 0.00882 · · ·
106
Lemma 1.11. Best approximations of the second kind are also of the first kind.
p
Proof. Suppose that q is a best approximation of the second kind to x. Then |qx − p| < |bx − a| for
a p
all b ≤ q where b 6= q . But then

x − = 1 |qx − p| < 1 |bx − a| = b


p a a

x ≤ x −



q q q q b b

p
since b ≤ q. It follows that q is a best approximation of the first kind.

We now see the link-up with continued fractions.

Theorem 1.12. The convergents of x are precisely the best approximations of the second kind, with one caveat:
p
if q2 = 1 (equivalently c2 = 1) then q11 = p1 = c1 is not a best approximation of the second kind, for the
p2
second convergent q2 = p2 = c2 = c1 + 1 will also be an integer, and a better approximating integer than c1 .
p
Proof. Suppose that ba 6= qnn with 1 ≤ b ≤ qn . Following Lagrange, we consider solutions to a certain
system of linear equations.

13
Recall that qn+1 = qn cn+1 + qn−1 for all n ≥ 1. Since the cn+1 are positive integers, it follows that
qn+1 ≥ qn . The only way to get equality is if n = 1 and c2 = 1, exactly the caveat in the theorem. We
may therefore assume that qn+1 > qn ≥ b.
Consider the matrix equation

p n p n +1 y a
    
=
q n q n +1 z b

Since the determinant of the matrix is ±1, there is a unique integer solution ( yz ). We check cases:

1. If both y, z are zero we have a contradiction, for b 6= 0.

2. If y = 0 and z 6= 0, then b = qn+1 z =⇒ b ≥ qn+1 , a contradiction.


a pn
3. If z = 0 and y 6= 0, then ypn = a and yqn = b forces b = qn , another contradiction.

4. Finally, if both y, z are non-zero, then 0 < b = yqn + zqn+1 < qn+1 forces y, z to have opposite
signs. Since the convergents alternate either side of x, we see that qn x − pn and qn+1 x − pn+1
also have opposite signs. Therefore y(qn x − pn ) and z(qn+1 x − pn+1 ) have the same sign and
thus

|bx − a| = |(yqn + zqn+1 ) x − (ypn + zpn+1 )| = |y(qn x − pn ) + z(qn+1 x − pn+1 )|


= |y(qn x − pn )| + |z(qn+1 x − pn+1 )| (terms have same sign)
> |y(qn x − pn )| ≥ |qn x − pn |

pn
In the non-contradictory case, the conclusion is b ≤ qn =⇒ |bx − a| > |qn x − pn |, whence qn is a
best approximation of the second kind.
If you read the above carefully and perform a small modification, we actually get the converse! As-
sume ba is not a convergent of x: we may assume that qn ≤ b < qn+1 for some n. All four cases of the
above analysis still hold, as does the conclusion

|bx − a| > |qn x − pn |


a
However, since qn ≤ b it follows that b cannot be a best approximation of the second kind.

It can also be proved that the best approximations of the first kind are the convergents and some of
their intermediate fractions: rational numbers of the form
p n +1 m + p n
q n +1 m + q n

where m is an integer. In fact the integers m which work are (roughly) those between 12 cn+2 and cn+2 .
We won’t pursue this.

The primary application however is done. In the days before calculators, if one wanted a rational
approximation of a number of desired accuracy, one needed only compute whichever convergent
was necessary to achieve this. The same could even be used for rational numbers. For example,

14
suppose we want to find the best approximation to 317
122 out of all fractions with a denominator at
most 5. We would start by computing the continued fraction and the convergents:
317
= [2; 1, 1, 2, 24]
122
n 0 1 2 3 4 5
cn 2 1 1 2 24
pn 1 2 3 5 13 317
qn 0 1 1 2 5 122
Clearly 13
317 13 1 1
5 is the answer: indeed 122 − 610 , so the estimate is very accurate, as well as


5 = 5·122 =
being much easier to work with.

Hurwitz’s Theorem In the next section we shall apply the discussion of convergents to the famous
Pell Equation. To help link this to continued fractions, we shall need the following results.
Theorem 1.13. Suppose x is a given irrational number.
a
1. There are infinitely many rational numbers b satisfying
a 1
x − < 2

b b
a
2. If is a rational number (b ∈ N) in lowest terms satisfing
b
a 1
x − < 2 (∗)

b 2b
a
then b is a best approximation of the second kind to x (and thus a convergent of x).
Proof. Part 1 is a corollary of Theorem 1.8: every convergent of x satisfies this inequality. For part 2,
suppose ba satisfies (∗) but is not a best approximation of the second kind. Then there must be some
n such that
q n ≤ b < q n +1
pn
Since the convergents are the best approximations of the second kind, it follows that qn is closer to x
(in the second sense) than ba : thus
|qn x − pn | ≤ |bx − a|
By (∗), we have,
1 pn 1

|qn x − pn | ≤ |bx − a| < =⇒ x − <

2b qn 2bqn
But then
1 | aqn − bpn | a pn

a pn
≤ = − (| aqn − bpn | is a positive integer since b 6= qn )
bqn bqn b q
n
a pn

≤ x − + x − (4-inequality)

b qn
1 1
< +
2b2 2bqn
But this is iff qn > b, a contradiction.

15
Note the distinction between the two parts of the theorem: we’d like to have an if and only if, but the
result isn’t there.

• ba a convergent of x =⇒ x − ba < b12


• x − ba < 2b12 =⇒ ba is a convergent of x.


A simplified version of Hurwitz’s Theorem states that, for a given irrational number x, there are
infinitely many rational numbers ba satisfying (∗): by the above, all such must be convergents of x.
Indeed, one can prove that at least one out of any two successive convergents satisfies (∗). The result
can be improved as far as the following, though we won’t prove it.
a
Theorem 1.14 (Hurwitz). If x is irrational, then there are infinitely many rational numbers b which satisfy
a 1
x − < √ 2

b 5b
Indeed all such must be convergents of x, and at least one of every three consecutive convergents satisfies the
inequality.
√ √
By thinking about the convergents of the golden ratio ϕ = 52+1 , one can see that 5 is the largest
number which can be placed in the denominator without ruling out some examples.

√ √
pn

Example Here is a table of the first ten convergents of 13 with a check on the accuracy of 13 −

qn
p1
each time: note that the first convergent q1 = 3 is not a best approximation, so strictly we should ig-
nore it.
n 1 2 3 4 5 6 7 8 9 10 11 12 13
pn 3 4 7 11 18 119 137 256 393 649 4287 4936 9223
qn 1 1 2 3 5 33 38 71 109 180 1189 1369 2558
√ p 1

13 − < n
?

X X X X X X X X
qn 2q2n
√ p 1

n
In fact all of the convergents checked also satisfy 13 − < √ .

qn 5q2n

16

You might also like