Continued Fractions
A finite continued fraction is an expression of the form
1
a0 +
1
a1 +
a2 +
.. .
.
1
+
1
an1 +
an
It can also be written as [a0 ; a1 , a2 , . . . , an ].
Finite continued fractions with integer terms represent rational numbers.
Every rational number can be expressed as a finite continued fraction using the Euclidean Algorithm,
but the expression is not unique.
The kth convergent of [a0 ; a1 , a2 , . . . , an ] is (the value of) the continued fraction [a0 ; a1 , a2 , . . . , ak ].
The convergents oscillate about the value of the continued fraction.
The convergents of a continued fraction may be computed from the continued fraction using a recursive
algorithm. The algorithm produces rational numbers in lowest terms.
Example.
47 13 1 1 1 1
=2+ =2+ = 2+ =2+ = 2+ .
17 17 17 4 1 1
1+ 1+ 1+
13 13 13 1
3+
4 4
47
In short form, = [2; 1, 3, 4].
17
A little bit of thought should convince you that you can express any rational number as a finite continued
fraction in this way. In fact, the expansion corresponds to the steps in the Euclidean algorithm. First,
47 = 2 17 + 13
1
17 = 1 13 + 4
13 = 3 4 + 1
4=41+0
a q
47 -
17 2
13 1
4 3
1 4
Notice that the successive quotients 2, 1, 3, and 4 are the numbers in the continued fraction expansion.
117
Example. Find the finite continued fraction expansion for .
17
a q
117 -
17 6
15 1
2 7
1 2
117 1
= [6; 1, 7, 2] = 6 + .
17 1
1+
1
7+
2
Lemma. Every finite continued fraction with integer terms represents a rational number.
2
Inductively, suppose that a finite continued fraction with n 1 levels is a rational number. I want to
show that
1
a0 +
1
a1 +
a2 +
..
.
1
+
1
an1 +
an
is rational.
By induction,
1
x = a1 +
1
a2 +
a3 +
..
.
1
+
1
an1 +
an
is rational.
So
1 1
a0 + = a0 +
1 x
a1 +
a2 +
..
.
1
+
1
an1 +
an
is the sum of two rational numbers, which is rational as well.
Example. The continued fraction expansion of a rational number is not unique. For example,
47 1 1
= 2+ =2+ .
17 1 1
1+ 1+
1 1
3+ 3+
4 1
3+
1
And in general,
[a0 ; a1 , a2 , . . . , an1 , an ] = [a0 ; a1 , a2 , . . . , an1 , an 1, 1].
I want to talk about infinite continued fractions things that look like
1
a0 +
1
a1 +
1
a2 +
a3 +
..
.
3
In preparation for this, Ill look at the effect of truncating a continued fraction.
ck = [a0 ; a1 , a2 , . . . , ak ].
Example. [1; 2, 3, 2]
c0 = 1
1 3
c1 = 1 +
=
2 2
1 10
c2 = 1 + =
1 7
2+
3
1 23
c3 = 1 + =
1 16
2+
1
3+
2
23
And c4 = c5 = = as well.
16
The next result gives an algorithm for computing the convergents of a continued fraction. Its important
for theoretical reasons, too Ill need it for several of the proofs that follow. For the theorem, I wont assume
that the ai s are integers, since I will need the general result later on.
p 0 = a0 , q0 = 1
p1 = a1 a0 + 1, q1 = a1
pk = ak pk1 + pk2 , qk = ak qk1 + qk2 , k 2.
pk
Then the k-th convergent of [a0 ; a1 , a2 , . . . , an ] is ck = .
qk
Proof. First, note that
1 1
[b0 ; b1 , . . . , bk , bk+1 ] = b0 + = b0 ; b1 , . . . , bk +
1 bk+1
b1 +
b2 +
..
.
1
+
1
bk1 +
1
bk +
bk+1
4
Now Ill start the proof it will go by induction on k. For k = 0,
a0 p0
c0 = a 0 = = .
1 q0
And for k = 1,
1 a1 a0 + 1 p1
c1 = a 0 + = = .
a1 a1 q1
Suppose k 2, and assume that result holds through the k-th convergent. Then
1
ck+1 = [a0 ; a1 , . . . , ak , ak+1 ] = a0 ; a1 , . . . , ak + .
ak+1
pk
Now this is the k-th convergent of a continued fraction, so by induction this is , where pk and qk
qk
1
refer to a0 ; a1 , . . . , ak + (as opposed to [a0 ; a1 , . . . , ak , ak+1 ]). But what are the pk and qk for this
ak+1
fraction? Theyre given inductively by
1
Now pk2 , pk1 , qk2 , qk1 are the same for a0 ; a1 , . . . , ak + and [a0 ; a1 , . . . , ak , ak+1 ], as I noted
ak+1
1 1
at the start. On the other hand, the k-th term of a0 ; a1 , . . . , ak + is ak + . So
ak+1 ak+1
1
ak + pk1 + pk2
ak+1 ak+1 (ak pk1 + pk2 ) + pk1 ak+1 pk + pk1 pk+1
ck+1 = = = = .
1 ak+1 (ak qk1 + qk2 ) + qk1 ak+1 qk + qk1 qk+1
ak + qk1 + qk2
ak+1
(The next to the last equality also follows by induction.) This shows that the result holds for k + 1, so
the induction step is complete.
Example. [1; 2, 1, 2, 1]
ak pk qk ck
1 1 1 1
3
2 3 2 = 1.5
2
4
1 4 3 1.33333
3
11
2 11 8 = 1.375
8
15
1 15 11 1.36364
11
There is a pattern to the computation of the ps and qs which makes things pretty easy. To get the
5
next p, for instance, multiply the current a by the last p and add the next-to-the-last p.
a p q a p q
1 1 1 1 1 1
2 3 2 2 3 2
1 1 4 3
2 2
1 1
a p q a p q
1 1 1 1 1 1
2 3 2 2 3 2
1 4 3 1 4 3
2 11 8 2 11 8
1 1 15 11
p 3= (2)(4) + 3 = 11 p 4= (1)(11) + 4 = 15
q 3= (2)(3) + 2 = 8 q 4= (1)(8) + 3 = 11
Notice that the convergents oscillate, and that the fractions which give the convergents are always in
lowest terms.
Example. [1; 1, 3, 1, 3]
ak pk qk ck
1 1 1 1
1 2 1 2
7
3 7 4 = 1.75
4
9
1 9 5 = 1.8
5
34
3 34 19 1.78947
19
Again, notice that the convergents oscillate, and that the fractions for the convergents are always in
lowest terms.
Ill prove that the convergent fractions are in lowest terms first.
p 0 = a0 , q0 = 1
p1 = a1 a0 + 1, q1 = a1
6
Corollary. Let a0 , a1 , . . . , an be positive integers. Let
p 0 = a0 , q0 = 1
p1 = a1 a0 + 1, q1 = a1
pk = ak pk1 + pk2 , qk = ak qk1 + qk2 , k 2.
pk
For k 1, is in lowest terms.
qk
Proof. pk qk1 pk1 qk = (1)k1 = 1 implies that (pk , qk ) = 1.
Proof of the Theorem. Ill induct on k. For k = 1,
p1 q0 p0 q1 = (a1 a0 + 1)(1) (a0 )(a1 ) = 1 = 111 .
Take k > 1, and assume the result holds for k. Then
pk+1 qk pk qk+1 = (ak+1 pk + pk1 )qk pk (ak+1 qk + qk1 ) = pk1 qk pk qk1 =
pk qk1 pk1 qk = (1)k1 = (1)k1 = (1)k .
This proves the result for k + 1, so the general result is true by induction.
1+ 5
Example. Ill show later that (the golden ratio) has the infinite continued fraction expansion
2
[1; 1, 1, . . .]. Here are the first ten convergents:
ak pk qk ck
1 1 1 1
1 2 1 2
1 3 2 1.5
1 5 3 1.66667
1 8 5 1.6
1 13 8 1.625
1 21 13 1.61538
1 34 21 1.61905
1 55 34 1.61765
1 89 55 1.61818
1+ 5 1+ 5
In fact, 1.61803. In this case, you can see formally that [1; 1, 1, . . .] should be . Let
2 2
1
x =1 +
1
1+
1
1+
1+
..
.
Notice that x contains a copy of itself as the bottom of the first fraction! So
1
x = 1 + , x2 = x + 1, x2 x 1 = 0.
x
1 5 1+ 5
The roots are . Since the fraction is positive, take the positive root to obtain x = .
2 2
c 2008 by Bruce Ikenaga 7