. Continued fractions. Notes on Continued Fractions for Math 4400 The continued fraction expansion converts a positive real number α into a sequence of natural numbers. Conversely, a sequence of natural numbers: a 0, a, a, a 3,... is converted into a sequence of rational numbers via: ( ) a 0, a 0 + a, a 0 + a +, a 0 + a a +, a + a 3 Thus, for example, the sequence 3, 7, 5, is converted into: 3 = 3, 3 + 7 = 7, 3 + 7 + 5 which are excellent approximations of π. = 333 06, 3 + 7 + 5+ = 355 3 We will find some useful general properties of continued fractions by replacing numbers a 0, a, a, a 3,... with a sequence of variables: q 0, q, q, q 3,... and considering the sequence of rational functions in many variables: q 0 = q 0, q 0 + = q 0q +, q 0 + q q q + = q 0q q + q 0 + q q q q + Definition. Define polynomials f n and g n by: (in lowest terms). q 0 + q +...+ qn = f n(q 0,..., q n ) g n (q,..., q n ) Examples. (o) f 0 (q 0 ) = q 0 and g 0 =. (i) f (q 0, q ) = q 0 q + and g (q ) = q. (ii) f (q 0, q, q ) = q 0 q q + q 0 + q and g (q, q ) = q q +. Proposition. (a) (Each g is an f) g n (q,, q n ) = f n (q,..., q n ). (b) (Recursion) f n (q 0,, q n ) = q 0 f n (q,, q n )+f n (q,, q n ).
Proof. By definition of the polynomials f n and g n, we have: hence: q 0 + q + q +... + qn q +...+ qn = q 0 + = f n (q,..., q n ) g n (q,..., q n ) ( fn (q,...,q n) g n (q,...,q n) ) = q 0 + g n (q,..., q n ) f n (q,..., q n ) = q 0f n (q,..., q n ) + g n (q,..., q n ) f n (q,..., q n ) and the denominator gives us (a), and the numerator gives us: f n (q 0,..., q n ) = q 0 f n (q,..., q n ) + g n (q,..., q n ) which, with g n (q,..., q n ) = f n (q,..., q n ) from (a), gives us (b). Using the recursion, we can get a few more of these polynomials: Example. (iii) f 3 (q 0, q, q, q 3 ) = q 0 (q q q 3 + q + q 3 ) + (q q 3 + ) (iv) f 4 (q 0, q, q, q 3, q 4 ) = = q 0 q q q 3 + q 0 q + q 0 q 3 + q q 3 + = q 0 (q q q 3 q 4 + q q + q q 4 + q 3 q 4 + ) + q q 3 q 4 + q + q 4 = q 0 q q q 3 q 4 + q 0 q q + q 0 q q 4 + q 0 q 3 q 4 + q q 3 q 4 + q 0 + q + q 4 Notice that the first term is always the product of all the q s. In fact: Euler s Continued Fraction Criterion: f n = q 0 q n + q 0 q n + q i i q i+ i j > q 0 q n q i q i+ q j q j+ + i.e. the other terms are obtained by removing consecutive pairs of q s from the product of all the q s. Example. f 5 = q 0 q 5 + q q 3 q 4 q 5 + q 0 q 3 q 4 q 5 + q 0 q q 4 q 5 + q 0 q q q 5 + q 0 q q q 3 + +q 4 q 5 + q q 5 + q q 3 + q 0 q 5 + q 0 q 3 + q 0 q + Proof. The criterion is true for f 0 (q 0 ) = q 0 and f (q 0 q ) = q 0 q +. By the recursive formula (b) above: f n (q 0,..., q n ) = q 0 f n (q,..., q n ) + f n (q,..., q n )
By induction, f n and f n may be assumed to satisfy the criterion, and it then follows from the formula that f n also satisfies the criterion! Corollary. (The palindrome corollary) f n (q 0,..., q n ) = f n (q n,..., q 0 ) Proof. Euler s criterion defines the same polynomial when the order of the variables is reversed. The most important corollary is now the following. Corollary. (An even better recursion) f n (q 0,..., q n ) = q n f n (q 0,..., q n ) + f n (q 0,..., q n ) Proof. Using Corollary and Proposition (b), we have: f n (q 0,..., q n ) = f n (q n,..., q 0 ) = q n f n (q n,..., q 0 )+f n (q n,..., q 0 ) = = q n f n (q 0,..., q n ) + f n (q 0,..., q n ) This corollary, together with the initial conditions: f 0 (q 0 ) = q 0, f (q 0, q ) = q 0 q + is going to turn out to be extremely useful. Back to Numbers. We now apply the polynomial results to continued fractions associated to natural numbers. Definition. Given a sequence of natural numbers a 0, a, a,..., let: (a) A n := f n (a 0, a,..., a n ) and (b) B n := g n (a,..., a n ) = f n (a,..., a n ) Gathering together what we have done with polynomials, we have: Proposition. (a) The sequence of rational numbers (*) coming from the sequence of natural numbers a 0, a, a,... is: A 0 = a 0 B 0, A = a 0a + A A 3,,,... B a B B 3 (b) The numbers A n and B n satisfy the Fibonacci-like rule: A n = a n A n + A n and B n = a n B n + B n for n Proof. (a) is from the definition, and (b) follows from Corollary. Example. Taking the sequence 3, 7, 5, again, we have: A 0 = 3, A =, A = 5 + 3 = 333, A 3 = 333 + = 355 B 0 =, B = 7, B = 5 7 + = 06, B 3 = 06 + 6 = 3 giving the sequence of rational approximations to π that we saw earlier. 3
4 Another Example. Take the sequence,,,,.... We have: A 0 =, A =, A = + = 3, A 3 = 3+ = 5, A 4 = 5+3 = 8,... B 0 =, B =, B = + =, B 3 = + = 3, B 4 = 3+ = 5,... which are two copies of the Fibonacci sequence offset by one. The associated sequence of rational numbers: 3,,, 5 3, 8 5, 3 8, 3,... converges pretty rapidly to the golden mean φ = ( + 5)/.. Convergence. We now have some powerful tools for analyzing the sequence of rational numbers that arise from a continued fraction. Proposition 3. Let a 0, a, a,... be a sequence of natural numbers, and let A n and B n be the natural numbers from Proposition. Then: (a) Each quadruple of numbers A n, B n, A n+, B n+ satisfies: A n+ B n A n B n+ = ( ) n (b) Each pair (A n, B n ) is relatively prime so A n /B n is in lowest terms. (c) If the sequence a 0, a, a,... is infinite, then there is a limit: A n lim = α and each n B n α A n B n < < B n B n+ Bn Proof. We prove (a) by induction. First of all: A B 0 A 0 B = (a 0 a + ) a 0 a = ( ) 0 = Using Proposition (b), we have: A n+ B n+ A n+ B n+ = (a n+ A n+ +A n )B n+ A n+ )(a n+ B n+ +B n ) = A n B n+ A n+ B n = ( )(A n+ B n A n B n+ ) which proves it. Then (b) follows directly from (a), since any common factor of A n and B n would be a factor of ( ) n. Finally, for (c), we notice that (a) also gives us: A n+ A n = ( )n B n+ B n B n B n+ which means that the differences of consecutive terms in the sequence: A 0 A A A 3,,,,... B 0 B B B 3 are alternating in sign and decreasing to zero. This implies that the sequence has a limit, and that the limit is between any two consecutive terms, which gives (c).
5 Example. The sequence,,,,... gives: A 0 =, A = 3, A = 7, A 3 = 7, A 4 = 4 B 0 =, B =, B = 5, B 3 =, B 4 = 9 which give rational numbers: A 0 A A A 3 A 4 =, =.5, =.4,.47,.44 B 0 B B B 3 B 4 that alternate above and below, and seem to converge to it. Getting to the point (finally) which is to convert α into a i s. Case. α = r 0 is a rational number > in lowest terms r Apply the Euclidean algorithm to the (relatively prime) pair (r 0, r ): r 0 = a 0 r + r ; r = a r + r 3 ; r n = a n r n + ; r n = a n + 0; But the right column gives us: α = a 0 + r = a 0 + r which exactly tells us that. r 0 = a 0 + r r r r = a + r 3 r r r n r n r n = a n a + r r3 = = a 0 + = a n + r n a +... a n + an α = r 0 = A n r B n for the (finite!) sequence a 0, a,..., a n of natural numbers. Bonus! From Proposition 3(a), we get: r 0 B n r A n = ( ) n which tells us precisely how to solve the equation: with integers (x, y). r 0 x + r y =
6 Example. α = 6/48. 6 = 48 + 3 48 = 3 3 + 9 3 = 9 + 4 9 = 4 + 4 = 4 + 0 The algorithm terminates with an output of:, 3,,, 4. Rebuilding: A 0 = B 0, A = 4 B 3, A = 5 B 4, A 3 = 4 B 3, A 4 = 6 B 4 48 gives the bonus equation 6 48 4 =. Case. α > is irrational. In this case there is no Euclidean algorithm, but we may define: [α] is the round down of α to the nearest integer, and {α} = α [α] is the fractional part of α. Then we get an infinite sequence of natural numbers a 0, a, a,... : α = a 0 + α, letting a 0 = [α] and α = {α} α = a + α, letting a = [α ] and α = {α } α = a + α 3, letting a = [α ] and α 3 = {α } etc. Claim. The sequence of rational numbers {A n /B n } coming from the sequence {a n } converges to the number α that we started with. Proof of Claim. From the definitions above, we have: α = a 0 + = a 0 + α a + = a 0 + α a + = a + α 3 and our polynomial results tell us that: α = f n+(a 0,..., a n, α n+ ) f n (a,..., a n, α n+ ) which, by Corollary, tells us that: α = α n+f n (a 0,..., a n ) + f n (a 0,..., a n ) α n+ f n (a,..., a n ) + f n (a,..., a n ) = α n+a n + A n α n+ B n + B n But it is easy to check that this number is between An B n since this is true for all n, it follows that α is the limit! and A n B n, and
3. Periodic Continued Fractions. A purely periodic continued fraction is associated to a sequence of natural numbers of the form: If we let: then we get: a 0, a,..., a n, a 0, a,..., a n, a 0, a,..., a n,... A n α = lim n B n α = a 0 + a +... + an+ α from which we may conclude, as in the proof of the claim above, that: α = αa n + A n αb n + B n so α is a root of the quadratic equation: B n x + (B n A n )x A n = 0 and one can solve for α with the quadratic formula. Examples. (i) Expansions of the form: a, a, a, a, a,... give α = a + /α so α is a root of the equation x ax = 0 and since α >, we conclude that: α = a + a + 4 (a) When a = we get the golden mean, α = ( + 5)/. (b) When a = k is even, we get α = k + k + so: k, k, k, k,... is the expansion for k + (ii) Expansions of the form: k, k, k, k,... give α which is a root of: 0 = B x +(B 0 A )x A 0 = k(x kx ) and therefore: α = k + 4k + 8 = k + k + Thus it follows that: k, k, k, k, k,... is the expansion of k + 7
8 (iii) Expansions of the form: k,, k,, k,... give α which is a root of x kx k = 0, so: α = k + 4k + 8k = k + k + k and square roots k + k = (k + ) have expansions: (iv) Expansions of the form: k,, k,, k,... k,, k,, k,... give α which is a root of (x kx k) = 0 so: α = k + 4k + 4k = k + k + k and square roots of the form k + k have expansions: k,, k,, k,... Question. Which α > have purely periodic continued fractions? We know each such α is an irrational root of a quadratic equation. Definition. Suppose ax + bx + c = 0 is a quadratic equation, and b 4ac is not a perfect square Then we will say that the roots are a conjugate pair (α, α). Example. (a) If b 4ac < 0, then α, α are complex numbers and they are conjugates in the ordinary sense. (b) The conjugate of the golden mean α = ( + 5)/ is ( 5)/. (c) The conjugate of k (when k is not a perfect square) is k. Theorem. The α > with purely periodic continued fractions: (i) Are irrational numbers, which (ii) Are roots of a quadratic ax + bx + c = 0 with a, b, c Z and (iii) Have a conjugate root α that satisfies < α < 0. Example. Any α of the form: α = k + k + m with 0 < m k is irrational, a root of the quadratic equation: x kx m = 0 and has conjugate root α = k k + m < 0 satisfying < α < 0.
4. Pell s Equation. We seek a solution to an equation of the form: x dy = where d > 0 is a natural number that is not itself a perfect square. Strategy. Such a solution satisfies (x y d)(x + y d) = hence: x y d = x + y d and 0 < x y d = y(x + y d) < y Such good approximations of an irrational ( d) by a rational (x/y) are precisely what continued fraction expansions produce. For example, the continued fraction expansion of 7 is,,,, 4,,,, 4,... and the associated sequence of rational numbers: satisfy, respectively:, 3, 5, 8 3,... 7 = 3 3 7 = 5 7 = 3 8 7 3 = and (8, 3) is a solution to Pell s equation. A more involved example is 3, whose expansion is: producing the sequence: which satisfy: 3,,,,, 6,,,,, 6,... 3, 4, 7, 3, 8 5, 3 3 = 4 4 3 = 3 7 3 = 3 3 3 = 4 8 3 5 = and although (8, 5) only solves x 3y =, we know how to convert that to a solution to Pell s equation by squaring: (8 5 3) = (34 + 5 3) 80 3 = 649 80 3 giving the solution (649, 80). 9
0 Proposition 4. Let: a 0 k, a,..., a n, a 0, a,..., a n,... be the continued fraction expansion of k + m (m k). Then either: (a) n is even, and: or else (b) n is odd, and: A n (k + m) B n = A n (k + m) B n = In the latter case, Pells equation is solved, and in the former: (A n B n k + m) = (A n + (k + m)b n) A n B n k + m solves it with the pair (A n + (k + m)b n, A n B n ). Proof. α = k + k + m has periodic expansion: Let β = k + m. Then: a 0,, a,..., a n, a 0,..., a n,... β = αa n + A n αb n + B n = (β + k)a n + A n (β + k)b n + B n from which it follows that β is a root of the polynomial: B n x (kb n + B n A n )x (ka n + A n ) = 0 But β = k + m, so β is a root of the polynomial: and it follows that: (i) kb n + B n A n = 0 and (ii) ka n + A n = (k + m)b n. x (k + m) = 0 Multiplying (i) through by A n gives us: ka n B n + A n B n A n = 0 and Proposition 3(a) gives us A n B n = A n B n + ( ) n hence: ka n B n +A n B n +( ) n A n = (ka n +A n )B n A n+( ) n = 0 and then (ii) gives: (k + m)b n A n = ( ) n which is exactly what we needed to prove.
Final Remarks. Our examples from 3 give us the following expansions: k + m (k, m) expansion (, ), 3 (, ),, 5 (, ), 4 6 (, ),, 4 7 (, 3) not from the examples 8 (, 4),, 4 0 (3, ) 3, 6 (3, ) 3, 3, 6 (3, 3) 3,, 6 3 (3, 4) not from the examples 4 (3, 5) not from the examples 5 (3, 6) 3,, 6 and while these expansions are predictable, the others are mysterious: () 7 has expansion,,,, 4 () 3 has expansion 3,,,,, 6 (3) 4 has expansion 3,,,, 6 and some really long periods appear for small numbers. For example: 46 has expansion 6,, 3,,,, 6,,,, 3,, leading to an enormous smallest solution to Pell s equation of (4335, 3588).