* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download MTH6128 Number Theory 5 Periodic continued fractions
Positional notation wikipedia , lookup
Law of large numbers wikipedia , lookup
Location arithmetic wikipedia , lookup
Vincent's theorem wikipedia , lookup
Wiles's proof of Fermat's Last Theorem wikipedia , lookup
Georg Cantor's first set theory article wikipedia , lookup
Mathematical proof wikipedia , lookup
Collatz conjecture wikipedia , lookup
Real number wikipedia , lookup
Elementary algebra wikipedia , lookup
List of important publications in mathematics wikipedia , lookup
Fundamental theorem of algebra wikipedia , lookup
Factorization wikipedia , lookup
Proofs of Fermat's little theorem wikipedia , lookup
Continued fraction wikipedia , lookup
Quadratic reciprocity wikipedia , lookup
MTH6128 Number Theory Notes 5 5 Spring 2017 Periodic continued fractions Continued fractions give a very useful way of representing real numbers if you are interested in finding good approximations; also we will soon see uses of them in solving diophantine equations. But for ordinary arithmetic, they are hopeless: there is no simple rule even for adding two continued fractions. Here is an example. √ We have √ that 2 + 1 is the value of [2; 2, 2, 2, . . .] = [2;]. If we add it to itself, we get 2( 2 + 1) which is the value of [4; 1, 4, 1, . . .] = [4; 1].√Could you imagine a rule to produce this? Maybe. But adding again, we get 3( 2 + 1) which is the value of [7; 4, 8, 4, 8, . . .] = [7; 4, 8], and it is dificult to see how any rule would produce this. √ is the value of [4; 4, 4, 4, . . .] = But worse is to come.√We have that √5 + 2 √ [4;], but adding this to 2 + 1 we get 2 + 5 + 3 which is the value of [6; 1, 1, 1, 6, 8, 1, 2, 1, 2, 2, . . .]. We see no pattern at all, and it really stretches the imagination to see how any simple rule could produce this from [2;] + [4;]. √ In√fact, we are going to show in this chapter that the continued fraction for 2+ 5+3 is non-periodic: it never repeats. We will decide just which irrational numbers have periodic continued fractions: √ they are precisely the quadratic num√ bers. Now convince yourself that 2 + 5 + 3 does not satisfy a quadratic with rational coefficients. (Its minimal polynomial has degree 4.) Definition The infinite continued fraction [a0 ; a1 , a2 , . . .] is periodic if there exist integers k, l with k > 0 such that an+k = an for all n ≥ l. 1 If an+k = an for all n ≥ l, we write the continued fraction as [a0 ; a1 , a2 , . . . , al−1 , al , al+1 , . . . , al+k−1 ]. It is purely periodic if there exists k > 0 such that an+k = an for all n ≥ 0. The notation is similar to the one used for periodic decimals. For example, [2; 1, 2, 1, 2, 1, 2, 1, . . .] = [2; 1] [3; 5, 2, 1, 2, 1, 2, 1, . . .] = [3; 5, 2, 1]. We now calculate these two continued fractions. Let c be the value of [2; 1]. Then c = [2; 1, c] [2, 1, c] (by Proposition 3.3(b)) = [1, c] 3c + 2 = . c+1 √ 2 So c2 + c = 3c + 2, so that c√ − 2c − 2 = 0, or c = 1 ± 3. But c > 2, so we must take the plus sign; c = 1 + 3. Now let d be the value of [3; 5, 2, 1]. Then d = [3; 5, c] [3, 5, c] = [5, c] 16c + 3 = 5c + 1 √ 19 + 16 3 √ = 6+5 3 √ √ (19 + 16 3)(6 − 5 3) √ √ = (6 + 5 3)(6 − 5 3) √ 126 − 3 = . 39 Note that d, like c, is a “quadratic irrational”, an algebraic integer satisfying a quadratic equation. (We saw this already for c; and d satisfies (39x − 126)2 = 3.) 2 In this chapter we are going to show that the result suggested by these examples is true in general. A real number has a periodic continued fraction if and only if it is a quadratic irrational. We will also find which numbers have purely periodic continued fractions. We will apply these results to sums of squares and to a diophantine equation called Pell’s equation in the next chapter. Recall √ from Chapter 2 that a quadratic irrational x ∈ R is of the form x = u + v d, where u and v are rational numbers, v 6= 0, and d is a squarefree integer greater than 1. (We require v 6= 0 and d > 1 since, if either of these conditions failed, y would be rational.) Quadratic irrationals are precisely the roots of irreducible quadratics with rational coefficients. √ Definition √ If x = u + v d is a quadratic irrational, we define its conjugate to be x0 = u − v d. Note that x and x0 are the two roots of the same irreducible quadratic. Definition A reduced quadratic irrational is a quadratic irreducible x such that x and its conjugate x0 satisfy and − 1 < x0 < 0. √ √ In our worked example, c = 1 + 3 > 0 and −1 < c0 = 1 −√ 3 < 0, so c is a reduced quadratic irrational. On the other hand, d = (126 − 3)/39 > 1 but √ 0 d = (126 + 3)/39 is greater than d. So d0 is not reduced. x>1 We are going to prove the following result: Theorem 5.1 (a) A real number has periodic continued fraction if and only if it is a quadratic irrational. (b) A real number has purely periodic continued fraction if and only if it is a reduced quadratic irrational. There are four things to prove here, and the proofs will take the rest of this chapter. Claim 1 We begin by showing that a number with a purely periodic continued fraction is a reduced quadratic irrational. Let x be the value of [a0 ; a1 , . . . , ak−1 ]. We will suppose that k ≥ 3; the argument for k = 1, 2 is easy to do directly, or we can simply pretend that the period is longer than it is (for example, [2; 1] = [2; 1, 2, 1]). 3 We know that x is irrational, since the continued fraction for a rational number terminates. Also, just as we argued for the value c of [2; 1], we have x = [a0 ; a1 , . . . , ak−1 , x] xpk−1 + pk−2 , = xqk−1 + qk−2 where ci = pi /qi is the ith convergent of [a0 ; a1 , . . . , ak−1 ]. Hence x2 qk−1 + x(qk−2 − pk−1 ) − pk−2 = 0, so that x is a quadratic irrational. Also, a0 = ak ≥ 1 (remember that all terms except possibly the first in a continued fraction are positive), so x > a0 ≥ 1. It remains to show that the algebraic conjugate x0 of x satisfies −1 < x0 < 0. From the properties of quadratic equations, we have xx0 = −pk−2 /qk−1 < 0. Also, pk−1 ck−1 pk−2 , < = −x0 = xqk−1 xqk−1 x because pk−2 < pk−1 ; and also −x0 = pk−2 pk−2 ck−2 < = , xqk−1 xqk−2 x because qk−2 < qk−1 . One of k − 1 and k − 2, say j, is even; and we know from Corollary 3.8 that cj < x. So −x0 < 1, or x0 > −1. Now we have verified all parts of the definition of a reduced quadratic irrational. Claim 2 Next we show that any number with periodic continued fraction is a quadratic irrational. Let y be the value of [a0 ; a1 , . . . , am , am+1 , . . . , am+k ]. Let z be the value of [am+1√ ; . . . , am+k ]. By Proof 1, z is a (reduced) quadratic irrational, say z = u + v d, where u and v are rational numbers and d is a squarefree integer. We have [a0 , . . . , am , z] [a1 , . . . , am , z] [a0 , . . . , am ]z + [a0 , . . . , am−1 ] = . [a1 , . . . , am ]z + [a1 , . . . , am−1 ] y = [a0 ; a1 , . . . , am , z] = Let [a0 , . . . , am ] = A, [a0 , . . . , am−1 ] = B, [a1 , . . . , am ] = C, [a1 , . . . , am−1 ] = D (these are all positive integers). Then y = Az + B Cz + D 4 √ Au + B + Av d √ = Cu + D + Cv d √ √ (Au + B + Av d)(Cu + D − Cv d) = , (Cu + D)2 − (Cv)2 d √ which is a quadratic irrational since it has the form U + V d for some rational numbers U and V . Now our goal is to prove the converse of the last two results: if x is a [reduced] quadratic irrational, then its continued fraction is [purely] periodic. Let us begin with an example. √ √ Example Find the continued fraction of 2 + 7. Note that 2 + 7 is reduced: √ it is greater than 1, and its algebraic conjugate 2 − 7 lies between −1 and 0. x0 x1 x2 x3 x4 √ = 2 + 7, √ √ = 1/(2 + 7 − 4) = (2 + 7)/3, √ √ = 3/(2 + 7 − 3) = (1 + 7)/2, √ √ = 2/(1 + 7 − 2) = (1 + 7)/3 √ √ = 3/(1 + 7 − 3) = 2 + 7 = x0 √ a0 = b2 + 7c = 4 √ a1 = b(2 + 7)/3c = 1 √ a2 = b(1 + 7)/2c = 1 √ a3 = b(1 + 7)/3c = 1 √ So 2 + 7 is the value of [4; 1, 1, 1]. Note that all of x0 , x1 , x2 , x3 are reduced quadratic irrationals, and we can read off their continued fractions: for example, x2 is the value of [1; 1, 4, 1]. Other observations which will be important in the proof are that, in each case, √ xi = (Pi + 7)/Qi , where Pi and Q√ i are integers (the √ Pi are 2, 2, 1, 1, . . . and the Qi are 1, 3, 2, 3, . . .); and 0 < Pi < 7, 0 < Qi < 2 7. We will see that all these properties hold quite generally. Before we start the proofs, we introduce a slightly different way of writing quadratic irrationals. √ Lemma 5.2 (a) A real quadratic irrational can be written as x = (P + D)/Q, where P, Q are integers, D is a positive integer which is not a square, and Q divides D − P 2 . √ √ (b) If x is reduced, then 0 < P < D and 0 < Q < 2 D. √ Proof (a) We know that x = u + v d where u and v are rationals and d is squarefree. 5 Suppose first that v is positive. Let q be the least common multiple of the denominators of u and v, and u = p/q, v = r/q. Then p √ √ pq + q 2 r2 d p + r2 d p+r d = = x= . q q q2 Put P = pq, Q = q 2 , and D = q 2 r2 d, and note that Q divides P 2 − D. If v < 0, then write −x in the specified form and then replace Q by −Q. (b) Now suppose that x is reduced; recall that this √ means x > 1 and −1 < 0 0 x < 0, where x is the conjugate of x (so x = (P − D)/Q). Then √ √ • x > 0 > x0 , so (P + D)/Q > (P − D)/Q. Hence Q > 0. √ √ • x > 1 > −x0 , so (P + D)/Q > (−P + D)/Q. Hence P > 0. √ √ • x0 < 0, so P − D < 0. Hence P < D. √ √ √ • x > 1, so (P + D)/Q > 1. Hence Q < P + D < 2 D. 0 Claim 3 We show that a reduced quadratic irrational has a purely periodic continued fraction. The proof is quite long, so I begin by outlining the steps. Let x be a reduced quadratic irrational. • We show that, if we run one step of the continued fraction algorithm, that is, with x0 = 0 and a0 = bx0 c, x1 = 1/(x0 − a0 ), that x1 is also a reduced quadratic irrational. • It follows that all the numbers xn that come up in the algorithm are reduced quadratic irrationals. √ √ D)/Q , where 0 < P < D • So all these numbers x have the form (P + n n n n √ and 0 < Qn < 2 D. • Since there are only finitely many possibilities for Pn and Qn , we must eventually return to a value we saw before; the algorithm is periodic from this point. • Finally we show it is periodic right from the start, that is, purely periodic. 6 Now for the details! √ Suppose that x = P +Q D is a reduced quadratic irrational (P, Q ∈ Z, D ∈ Z, √ √ D > 0, D not a square, Q | D − P 2 , 0 < P < D, 0 < Q < 2 D). We start building the continued fraction for x0 = x. The first step is a = bxc, y= 1 . x−a ∗ √ + D Claim 3: y is a reduced quadratic number of the form P Q . ∗ Certainly y > 1, since y = 1/(x − a) and x − a < 1. We have to show that −1 < y 0 < 0. Let P ∗ = Qa − P . Then y = = = = = 1 √ (P + D)/Q − a 1 √ (P + D − Qa)/Q 1 √ ∗ (−P + D)/Q √ P∗ + D (D − (P ∗ )2 )/Q √ P∗ + D , Q∗ where Q∗ = (D − (P ∗ )2 )/Q. Now Q∗ = D − (Qa − P )2 D − P2 = −Qa2 + 2P a + , Q Q so Q∗ is an integer. Moreover, Q∗ divides D − (P ∗ )2 (the quotient is just Q). So we have written y in the same form as x, with the same D, but maybe different P and Q. Also, we have y = 1/(x − a), and so y 0 = 1/(x0 − a). Now x0 < 0, so x0 − a < −a ≤ −1; so −1 < y 0 < 0 (since x0 − a < 0), as required. Our claim is proved. Proof of Theorem 5.1 (b) ⇒√ is Claim 1. Let us prove ⇐: Let x be a 1 reduced quadratic number, x = P +Q D . Put x0 = x, ..., an = bxn c, xn+1 = xn −a . n By Claim 3 (induction), we know that xn = 7 √ Pn + D . Qn Pn and Qn are integers √ √ satisfying 0 < Pn < D and 0 < Qn < 2 D. There are only finitely many possible values of Pn and Qn , so after some number of steps, we must return to values we have seen before. Suppose this first happens when xn = xm . Clearly the sequence repeats after this point, that is, xi+k = xi for all i ≥ m, where k = n − m. We have to show that the repetition starts with m = 0. Let m > 0 be such that 1 1 = xn = , xm = xm−1 − am−1 xn−1 − an−1 so 1 1 x0m = 0 = x0n = 0 , xm−1 − am−1 xn−1 − an−1 So x0m−1 − am−1 = x0n−1 − an−1 . Thus x0m−1 and x0n−1 differ by an integer. But they both lie between −1 and 0, so they are equal, whence xm−1 = xn−1 . This allows us to go back to m = 0. So, finally, we have proved the converse implication in part (b) of the big theorem: that is, the irrational number x has a purely periodic continued fraction if and only if it is a reduced quadratic irrational. Proof of Theorem 5.1 (a) The final part is to prove part (a) of the theorem: the irrational number x has a periodic continued fraction if and only if it is a quadratic irrational. We have proved ⇒ in Claim 2. So suppose that x is a quadratic irrational; we have to show that its continued fraction is periodic (from some point on). Calculate its continued fraction: that is, put x0 = x, and then an = bxn c, xn+1 = 1 x n − an for n ≥ 0. It is clear that all the xn are quadratic irrationals, since subtracting an integer from a quadratic irrational, and taking the reciprocal of one, gives again a quadratic irrational. We have to prove that, for some value of n, the number xn is a reduced quadratic irrational. Then by part (b) of the Theorem, the continued fraction is periodic from that point on. So we have to prove that, if n is large enough, then xn > 1 and −1 < x0n < 0. By construction, we have xn > 1 for all n > 0, since xn = 1/(xn−1 − an−1 ) and xn−1 − an−1 < 1. So this part is easy! Also, we have for any n > 0 x = [a0 ; a1 , . . . , an−1 , xn ] = 8 xn pn−1 + pn−2 , xn qn−1 + qn−2 by standard results about continued fractions. Hence x0 pn−1 + pn−2 x0 = n0 , xn qn−1 + qn−2 so rearranging we obtain x0n −x0 qn−2 + pn−2 = 0 . x qn−1 − pn−1 So, taking factors qn−2 and qn−1 out of numerator and denominator, x0n = − qn−2 x0 − cn−2 , qn−1 x0 − cn−1 where cn is the nth convergent. (Remember that cn = pn /qn .) Since cn → x as n → ∞, we have − qn−1 0 x0 − x x0 − cn−2 xn = 0 → 0 =1 qn−2 x − cn−1 x −x as n → ∞. So for large enough n, we have |(x0 − cn−2 )/(x0 − cn−1 ) − 1| < 1, and so this fraction is positive. Thus −(qn−1 /qn−2 )x0n > 0, so that x0n < 0. Also, we can ensure that n is also large enough so that |cn − x| < |x0 − x|. If x0 < x, we use the fact that even-numbered convergents are smaller than x and odd-numbered convergents are greater; choosing n even, we have x0 < cn−2 < x < cn−1 . If x < x0 , then choosing n odd we have cn−1 < x < cn−2 < x0 . In either case, we have qn−2 x0 − cn−2 0 < 1, −xn = qn−1 x0 − cn−1 so finally we conclude that, for large enough n, −1 < x0n < 0 and xn is a reduced quadratic irrational, as required. The proof is complete. 9