Period of the Continued Fraction of N
Total Page:16
File Type:pdf, Size:1020Kb
√ Period of the Continued Fraction of n Marius Beceanu February 5, 2003 Abstract This paper seeks to recapitulate the known facts√ about the length of the period of the continued fraction expansion of n as a function of n and to make a few (possibly) original contributions. I have√ established a result concerning the average period length for k < n < k + 1, where k is an integer, and, following numerical experiments, tried to formulate the best possible bounds for this average length and for the √maximum length√ of the period of the continued fraction expansion of n, with b nc = k. Many results used in the course of this paper are borrowed from [1] and [2]. 1 Preliminaries Here are some basic definitions and results that will prove useful throughout the paper. They can also be probably found in any number theory intro- ductory course, but I decided to include them for the sake of completeness. Definition 1.1 The integer part of x, or bxc, is the unique number k ∈ Z with the property that k ≤ x < k + 1. Definition 1.2 The continued fraction expansion of a real number x is the sequence of integers (an)n∈N obtained by the recurrence relation 1 x0 = x, an = bxcn, xn+1 = , for n ∈ N. xn − an Let us also construct the sequences P0 = a0,Q0 = 1, P1 = a0a1 + 1,Q1 = a1, 1 √ 2 Period of the Continued Fraction of n and in general Pn = Pn−1an + Pn−2,Qn = Qn−1an + Qn−2, for n ≥ 2. It is obvious that, since an are positive, Pn and Qn are strictly increasing for n ≥ 1 and both are greater or equal to Fn (the n-th Fibonacci number). Let us define the n-th convergent 1 Rn = a0 + 1 a1 + 1 a2 + . 1 .. + an. Theorem 1.1 The following relations hold for n ≥ 2: Pn Pn−1an + Pn−2 Pn−1xn + Pn−2 Rn = = ; x = . Qn Qn−1an + Qn−2 Qn−1xn + Qn−2 The proof can be easily made by induction, and is also to be found in [2, Sect. 5.2.4]. Other well-known facts are that n Pn−1Qn − Qn−1Pn = (−1) . (also proven by induction) and that n Pn Pnxn+1 + Pn−1 Pn (−1) x − = − = Qn Qnxn+1 + Qn−1 Qn Qn(Qnxn+1 + Qn−1) 1 ≤ QnQn+1) It follows that limn→∞ Rn = x. In particular, the last result implies that two numbers whose continued fraction expansions coincide must be equal. 2 Periodicity of continued fractions Theorem 2.1 The continued fraction expansion of a real number x is pe- riodic from a point onward iff x is the root of some quadratic equation ax2 + bx + c = 0 with integer coefficients. Marius Beceanu 3 Proof The sufficiency is easier to prove. Indeed, if we know that an = an+p for all n ≥ N, then let us note that xN and xN+p have the same continued fraction and thus are equal. On the other hand, we know that 1 P˜p−1xN+p + P˜p−2 xN = aN + = 1 Q˜p−1xN+p + Q˜p−2 aN+1 + 1 aN+2 + . 1 .. + xN+p and therefore it satisfies the second-degree equation ˜ 2 ˜ ˜ ˜ Qp−1xN + (Qp−2 − Pp−1)xN − Pp = 0. At the same, let us remember that x = PN−1xN +PN−2 . By a trivial compu- QN−1xN +QN−2 −QN−2x+PN−2 tation we obtain that xN = . Therefore x satisfies a second- QN−1x−PN−1 degree equation with integer coefficients too, namely 2 Q˜p−1(−QN−2x+PN−2) +(Q˜p−2−P˜p−1)(−QN−2x+PN−2)(QN−1x−PN−1) 2 − P˜p(QN−1x − PN−1) = 0. The converse is slightly more difficult to prove. Assume that x satisfies the equation f(x) = ax2 + bx + c = 0. Then, since x = Pn−1xn+Pn−2 , it Pn−1xn+Pn−2 follows that each of the remainders xn, n ≥ 2, also satisfies the second- degree equation 2 a(Pn−1xn + Pn−2) + b(Pn−1xn + Pn−2)(Qn−1xn + Qn−2) 2 + c(Qn−1xn + Qn−2) = 0 2 or fn(xn) = Anxn + Bnxn + Cn = 0, where I have denoted 2 2 An = aPn−1 + bPn−1Qn−1 + cQn−1, Bn = 2aPn−1Pn−2 + b(Pn−1Qn−2 + Pn−2Qn−1) + 2cQn−1Qn−2, and 2 2 Cn = aPn−2 + bPn−2Qn−2 + cQn−2. To help with the subsequent computations, let us evaluate (R − x)2 |f(R )| = |f(R ) − f(x)| = (R − x)f 0(x) + n f 00(x) n n n 2 |f 0(x)| |f 00(x)| < + 2 2 Qn+1Qn Qn+1Qn 2|a||x| + |b| |a| ≤ + 2 2 . Qn+1Qn Qn+1Qn √ 4 Period of the Continued Fraction of n 2 Let us note that An = Qn−1f(Rn−1) and Cn = An−1; then, 2 Qn−1 0 |a| |An| = Qn−1|f(Rn−1)| ≤ |f (x)| + 2 Qn Qn ≤ 2|a||x| + |b| + |a| and the same goes for Cn. With respect to Bn, we can say that 2 Bn = Qn−1Qn−2(f(Rn−1) + f(Rn−2) − a(Rn−1 − Rn−2) ), so |a| |Bn| ≤ Qn−1Qn−2(|f(Rn−1| + |f(Rn−2)| + 2 2 ) Qn−1Qn−2 Qn−2 1 2 ≤ + 1 (2|a||x| + |b|) + 2 2 + 2 2 |a| Qn Qn−1Qn Qn−1Qn−2 3 5 ≤ (2|a||x| + |b|) + |a|. 2 2 Then, we have proven that all of An, Bn, and Cn can take a limited num- ber of values. Eventually, such a triple is bound to reoccur twice, making, some xk, xl, and xm roots of the same second-degree equation for distinct k, l, and m. Since a second-degree equation only has two roots, two of those numbers will have to be equal, say xk = xl. Then, ak+i = al+i for i ≥ 0, q. e. d. Actually, there is no need to wait for a triple to reoccur twice, because 2 xn cannot be both roots of the given equation. The original equation, ax + b bx + c = 0, has two roots, and the rational − 2a lies between them. Then, for n > c log |2a| (such that Qn > |2a|), the law of the best approximations b says that Rn is closer to x than − 2a (and than the other root). Therefore, the sign of f(Rn) only depends on the sign of Rn − x, from a point onward, and therefore it alternates. Then An and Cn have distinct signs, and, since xn is positive, the other root of fn must be negative. If the equation has two roots of different signs, xn must be the positive root. Then, if we repeat the above reasoning only counting the triples for n > c log 2a, we have proved the following Theorem 2.2 If x is the solution of the equation f(x) = ax2 + bx + c = 0 with integer coefficients, the length of the period of the continued fraction 0 2 3 0 5 expansion of x cannot exceed (|f (x)| + |a|) ( 2 |f (x)| + 2 |a|) + O(log |a|). If not much can be said in general about the period of a quadratic irra- tional x (after all, every periodic sequence of integers determines one such irrational), a lot is known about the continuous fraction expansion of irra- √ p tionals of the form D, for rational D = q . Marius Beceanu 5 √ Theorem 2.3 In the continued√ fraction expansion of D, the remainders (D)+b always take the form x = n , where the numbers b , c , as well as n cn n n the continued fraction digits an can be obtained by means of the following 2 algorithm: set a0 = bDc, b1 = a0, c1 = D − ao, and then compute 2 a0 + bn−1 D − bn an−1 = , bn = an−1cn−1 − bn−1, cn = . cn−1 cn−1 √ Proof We already know that D = Pn−1xn+Pn−2 , or equivalently Qn−1xn+Qn−2 √ √ √ −Qn−2 D + Pn−2 (Qn−2 D − Pn−2)(Qn−1 D + Pn−1) xn = √ = Q D − P P 2 − DQ2 n−1 √ n−1 n−1 n−1 n−1 (−1) D + DQn−1Qn−2 − Pn−1Pn−2 = 2 2 . Pn−1 − DQn−1 Then, we know precisely the values of bn and cn (which, in case they exist, must be unique, being rational), namely n bn = (−1) (Pn−1Pn−2 − DQn−1Qn−2) and (2.1) n 2 2 cn = (−1) (DQn−1 − Pn−1). The claims concerning the recurrence relation can be verified direcly. First, though, we need the following: Lemma 2.1 If k is a natural number and x a real number, then x bxc = . k k Its proof lies in [1, pp. 295-296]. By using this lemma, one can easily find that √ √ D + bn b D + bnc a0 + bn an = bxnc = = = , cn cn cn while a simple computation shows that √ √ D + bn−1 1 cn an−1 D + an−1bn + cn = xn−1 = an−1+ = an−1+√ = √ cn−1 xn D + bn D + bn and equivalently √ √ √ ( D + bn−1)( D + bn) = cn−1(an−1 D + an−1bn + cn) √ 6 Period of the Continued Fraction of n √ whence we get (since D is irrational) that bn−1 + bn = cn−1an−1 and D + bn−1bn = cn−1an−1bn + cn−1cn ⇔ 2 ⇔ D + bn(bn−1 − cn−1an−1) = bn + cn−1cn ⇔ D − bn = cn−1cn. 1 Then, the first terms of the sequences are easy to find: x1 = √ = √ D−a0 D+a0 2 2 .