Unisequences and nearest integer continued fraction midpoint criteria for Pell s equation Keith R. Matthews Department of Mathematics University of Queensland Brisbane Australia 4072 and Centre for Mathematics and its Applications Australian National University Canberra ACT 0200, Australia keithmatt@gmail.com Abstract. The nearest integer continued fractions of Hurwitz, Minnegerode (NICF-H) and in Perron s book Die Lehre von den Kettenbrüchen (NICF-P) are closely related. Midpoint criteria for solving Pell s equation x 2 Dy 2 = ±1 in terms of the NICF-H expansion of D were derived by H. C. Williams using singular continued fractions. We derive these criteria without the use of singular continued fractions. We use an algorithm for converting the regular continued fraction expansion of D to its NICF-P expansion. 1. Introduction In Perron s book [7, p. 143], a nearest integer continued fraction (Kettenbruch nach nächsten Ganzen) expansion (NICF-P) of an irrational number ξ 0 is defined recursively by ξ n = q n + ǫ n+1 ξ n+1, 1 2 < ξ n q n < 1 2, (1.1) where ǫ n+1 = ±1, q n is an integer (the nearest integer to ξ n ) and sign(ǫ n+1 ) = sign(ξ n q n ). Then we have the expansion where ξ 0 = q 0 + ǫ 1 q 1 + + ǫ n q n + (1.2) q n 2, q n + ǫ n+1 2 for n 1. (1.3) (Satz 10, [7, p. 169]). A. Hurwitz [1] and B. Minnegerode [6] defined a related nearest integer continued fraction (NICF-H) by ξ n = q n 1, ξ n+1 1 < 2 ξ n q n < 1, (1.4) 2 1
where q n is an integer. Then ξ 0 = q 0 1 q 1 1 q n (1.5) and we have q n 2 for n 1. Also if one of q 1,q 2,..., say q n, equals 2 (resp. 2), then q n+1 < 0 (resp. q n+1 > 0) (Hurwitz [1, p. 372]). Section 2 relates the two types of continued fraction. In 1980, H. C. Williams gave six midpoint criteria for solving Pell s equation x 2 Dy 2 = ±1 in terms of the NICF-H expansion of D (see Theorems 6 and 7, [9, pp. 12 13]). His proof made extensive use of the singular continued fraction expansion of D. Theorem 1 of section 3 of our paper gives the corresponding criteria for the NICF-P expansion of D. In an attempt to give a derivation of the latter criteria without the use of singular continued fractions, the author studied the conversion of the regular continued fraction (RCF) expansion of D to the NICF given by Lemma 2 of section 5, where the RCF is defined recursively by ξ n = a n + 1 ξ n+1, with a n = ξ n, the integer part of ξ n. Theorem 2 of section 4 shows that the central part of a least period determines which of the criteria hold. Finally, Theorem 3, section 7, describes the case where there are only odd-length unisequences, i.e., consecutive sequences of partial quotients equal to 1, in the RCF expansion of D; in this case the NICF-P expansion of D exhibits the usual symmetry properties of the RCF expansion. 2. Connections between the NICF-H and NICF-P expansions of an irrational number. Lemma 1. Let q n,ξ n,a n/b n denote the n-th partial denominator, complete quotient and convergent of the NICF-H expansion of an irrational number ξ 0 and q n,ǫ n,ξ n,a n /B n denote the n-th partial denominator, partial numerator, complete quotient and convergent of the NICF-P expansion of ξ 0, where A 1 = 1 = A 1, B 1 = 0 = B 1, A 2 = 0 = A 2, B 2 = 1 = B 2. and for n 1, A n+1 = q n+1 A n + ǫ n+1 A n 1, A n+1 = q n+1a n A n 1, B n+1 = q n+1 B n + ǫ n+1 B n 1 B n+1 = q n+1b n B n 1, where ǫ 0 = 1. Then q n = t n q n, ξ n = t n ξ n, n 0, (2.1) where t 0 = 1 and t n = ( 1) n ǫ 1 ǫ n, if n 1. A n = s n A n, B n = s n B n, n 2, (2.2) where s 2 = 1,s 1 = 1 and s n+1 = s n 1 ǫ n+1 for n 1. 2
Remark. It follows that s 0 = 1 and s 2i = ( 1) i ǫ 2i ǫ 2i 2 ǫ 2, if i 1, (2.3) s 2i+1 = ( 1) i+1 ǫ 2i+1 ǫ 2i 1 ǫ 1, if i 0, (2.4) s n+1 s n = t n+1, if n 1. (2.5) Proof. We prove (2.1) by induction on n 0. These are true when n = 0. So we assume that n 0 and (2.1) hold. Then ξ n+1 1 =, ξ q n ξ n n+1 = ǫ n+1, (2.6) q n ξ n q n = [ξ n], q n = [ξ n ], (2.7) where [x] denotes the nearest integer to x. Then ξ n+1 1 = t n q n t n ξ n = t n q n ξ n = t n ( ǫ n+1 ξ n+1 ) = t n+1 ξ n+1. Next, q n+1 = [ξ n+1] = [t n+1 ξ n+1 ] = t n+1 [ξ n+1 ] = t n+1 q n+1. Finally, we prove (2.2) by induction on n 2. These hold for n = 2 and 1. So we assume n 1 and Then A n 1 = s n 1 A n 1, B n 1 = s n 1 B n 1, A n = s n A n, B n = s n B n. Similarly B n+1 = s n+1 B n+1. A n+1 = q n+1a n A n 1 = (t n+1 q n+1 )(s n A n ) s n 1 A n 1 = q n+1 s n+1 A n ( s n+1 ǫ n+1 )A n 1 = s n+1 (q n+1 A n + ǫ n+1 A n 1 ) = s n+1 A n+1. Corollary 1. Suppose ξ n,...,ξ n+k 1 is a least period of NICF-P complete quotients for a quadratic irrational ξ 0. (a) If ǫ n+1 ǫ n+k = ( 1) k, then ξ n,...,ξ n+k 1 is a least period of NICF-H complete quotients for ξ 0. (b) If ǫ n+1 ǫ n+k = ( 1) k+1, then ξ n,...,ξ n+k 1, ξ n,..., ξ n+k 1 (2.8) is a least period of NICF-H complete quotients for ξ 0. Moreover ξ 0 = q 0 1 q 1 1 q n 1 q n+k 1 3 1 q n 1 q n+k 1,
where the asterisks correspond to the least period (2.8). Proof. Suppose ξ n,...,ξ n+k 1 is a least period of NICF-P complete quotients for ξ 0. Then ξ n = ξ n+k. Hence from (2.1), t n ξ n = t n+k ξ n+k ( 1) n ǫ 1 ǫ n ξ n = ( 1) n+k ǫ 1 ǫ n+k ξ n+k (a) Suppose ǫ n+1 ǫ n+k = ( 1) k. Then (2.9) gives ξ n = ( 1) k ǫ n+1 ǫ n+k ξ n+k. (2.9) ξ n = ξ n+k. Then because ξ n,...,ξ n+k 1 are distinct, they form a least period of complete quotients for the NICF-H expansion of ξ 0. (b) Suppose ǫ n+1 ǫ n+k = ( 1) k+1. Then (2.9) gives Similarly ξ n = ξ n+k. ξ n+1 = ξ n+k+1,...,ξ n+k 1 = ξ n+2k 1. Also ξ n = ξ n+k = ( ξ n+2k ) = ξ n+2k. Hence ξ n,...,ξ n+k 1,ξ n+k,...,ξ n+2k 1 (2.10) form a period of complete quotients for the NICF-H expansion of ξ 0. However sequence (2.10) is identical with ξ n,...,ξ n+k 1, ξ n,..., ξ n+k 1, whose members are distinct. Hence (2.10) form a least period of complete quotients for the NICF-H expansion of ξ 0. Corollary 2. Let k and p be the period-lengths of the NICF-P and RCF expansions of a quadratic irrational ξ 0 not equivalent to (1 + 5)/2. Then (a) if p is even, the period-length of the NICF-H expansion of ξ 0 is equal to k; (b) if p is odd, the period-length of the NICF-H expansion of ξ 0 is equal to 2k and the NICF-H expansion has the form ξ 0 = q 0 1 q 1 1 q n 1 q n+k 1 1 q n 1 q n+k 1 Proof. Let ξ n,...,ξ n+k 1 be a least period of NICF-P complete quotients. Suppose that r of the partial numerators ǫ n+1,...,ǫ n+k of the NICF-P expansion of ξ 0 are equal to 1. Now by Theorem 4 of Matthews and Robertson [5], p = k + r and hence ǫ n+1 ǫ n+k = ( 1) r = ( 1) k+p. Then according as p is even or odd, ǫ n+1 ǫ n+k = ( 1) k or ( 1) k+1 and Corollary 1 applies. Remark. This result was obtained by Hurwitz and Minnegerode for the special case ξ 0 = D. We give some examples. 4.
Table 1. NICF-P expansion for (12 + 1792)/16 i ξ i ǫ i b i A i /B i 0 12+ 1792 1 3 3/1 16 1 36+ 1792 1 3 10/3 31 2 57+ 1792 1 2 17/5 47 3 37+ 1792 1 9 163/48 9 4 44+ 1792 1 5 798/235 16 5 36+ 1792 1 3 2557/753 31 Table 2. NICF-H expansion for (12 + 1792)/16 i ξ i ǫ i b i A i /B i 0 12+ 1792 1 3 3/1 16 1 36+ 1792 1 3 10/ 3 31 2 57+ 1792 1 2 17/5 47 3 37+ 1792 1 9 163/48 9 4 44+ 1792 1 5 798/235 16 1 3 2557/ 753 5 36+ 1792 31 Table 3. NICF-P expansion for (5 + 13)/4 i ξ i ǫ i b i A i /B i 0 5+ 13 1 2 2/1 4 1 3+ 13 1 7 15/7 1 2 4+ 13 1 3 43/20 3 3 5+ 13 1 2 71/33 4 (1) ξ 0 = (12 + 1792)/16, (Tables 1 and 2). Here k = 4,r = 2, ξ 1,ξ 2,ξ 3,ξ 4 form a period of NICF-P complete quotients, ǫ 2 ǫ 3 ǫ 4 ǫ 5 = ( 1)(1)( 1)(1) = 1 = ( 1) k and the NICF-P and NICF-H expansions have the same period-length. Also p = 6. (2) ξ 0 = (5 + 13)/4, (Table 3 and 4). Here k = 3,r = 2 and ξ 0,ξ 1,ξ 2 form a period of NICF-P complete quotients, ǫ 1 ǫ 2 ǫ 3 = (1)( 1)( 1) = 1 = ( 1) k+1 and the NICF-H period-length is twice the NICF-P period-length. Also p = 5. 3. NICF-P midpoint criteria for Pell s equation Theorem 1. Let k and p be the respective period-lengths of NICF-P and RCF expansions of D. Then precisely one of the following must hold for the NICF-P expansion of D: 1) P ρ = P ρ+1, k = 2ρ,p = 2h. Then A k 1 = B ρ 1 A ρ + ǫ ρ A ρ 1 B ρ 2, B k 1 = B ρ 1 (B ρ + ǫ ρ B ρ 2 ). 5
Table 4. NICF-H expansion for (5 + 13)/4 i ξ i ǫ i b i A i /B i 0 5+ 13 1 2 2/1 4 1 3+ 13 1 7 15/ 7 1 2 4+ 13 1 3 43/20 3 3 5+ 13 1 2 71/ 33 4 4 3+ 13 1 7 540/ 251 1 5 4+ 13 1 3 1549/ 720 3 6 5+ 13 1 2 2558/ 1189 4 2) P ρ+1 = P ρ + Q ρ, k = 2ρ,p = 2h. Then 3) Q ρ = Q ρ+1 and Then A k 1 = B ρ 1 A ρ + A ρ 1 B ρ 2 A ρ 1 B ρ 1, B k 1 = B ρ 1 (B ρ + B ρ 2 B ρ 1 ). (a) ǫ ρ+1 = 1,k = 2ρ + 1,p = 2h, or (b) ǫ ρ+1 = 1,k = 2ρ + 1,p = 2h 1. A k 1 = A ρ B ρ + ǫ ρ+1 A ρ 1 B ρ 1, B k 1 = B 2 ρ + ǫ ρ+1 B 2 ρ 1. 4) P ρ+1 = Q ρ + 1 2 Q ρ+1,ǫ ρ+1 = 1,k = 2ρ + 1,p = 2h 1. Then A k 1 = A ρ B ρ + 2A ρ 1 B ρ 1 (A ρ B ρ 1 + B ρ A ρ 1 ), B k 1 = B 2 ρ + 2B 2 ρ 1 2B ρ B ρ 1. 5) P ρ = Q ρ + 1 2 Q ρ 1,ǫ ρ = 1,k = 2ρ,p = 2h 1. Then A k 1 = 2A ρ 1 B ρ 1 + A ρ 2 B ρ 2 (A ρ 1 B ρ 2 + B ρ 1 A ρ 2 ) B k 1 = 2B 2 ρ 1 + B 2 ρ 2 2B ρ 1 B ρ 2. Proof. We only exhibit the calculations for criterion 1) of Theorem 1. This corresponds to criterion 1) of Theorem 6, Williams [9, p. 12], which states that P ρ = P ρ+1, k = 2ρ, p = 2h and Then from equations (2.2), A k 1 = B ρ 1A ρ A ρ 1B ρ 2, (3.1) B k 1 = B ρ 1(B ρ B ρ 2). (3.2) B ρ 1A ρ A ρ 1B ρ 2 = s ρ 1 s ρ B ρ 1 A ρ s ρ 1 s ρ 2 A ρ 1 B ρ 2 = t ρ B ρ 1 A ρ t ρ 1 A ρ 1 B ρ 2 = t ρ 1 ǫ ρ B ρ 1 A ρ t ρ 1 A ρ 1 B ρ 2 = t ρ 1 ǫ ρ (B ρ 1 A ρ + ǫ ρ A ρ 1 B ρ 2 ). 6
Hence B ρ 1A ρ A ρ 1B ρ 2 = B ρ 1 A ρ + ǫ ρ A ρ 1 B ρ 2 (3.3) as B ρ 1 A ρ A ρ 1 B ρ 2. Hence (3.1) and (3.3) give the first result of criterion 1) above. Next, B ρ 1(B ρ B ρ 2) = s ρ 1 B ρ 1 (s ρ B ρ s ρ 2 B ρ 2 ) = B ρ 1 (t ρ B ρ t ρ 1 B ρ 2 ) = B ρ 1 ( t ρ 1 ǫ ρ B ρ t ρ 1 B ρ 2 ) = t ρ 1 ǫ ρ B ρ 1 (B ρ + ǫ ρ B ρ 2 ). Hence B ρ 1(B ρ B ρ 2) = B ρ 1 (B ρ + ǫ ρ B ρ 2 ) (3.4) and (3.2) and (3.4) give the second result of criterion 1) above. Remark. John Robertson in an email to the author, dated November 26, 2007, noted the following errors in Williams [9, pp. 12 13]: (i) Criterion 3), Theorem 6, page 12, should be A π 1 = A ρb ρ A ρ 1B ρ 1, B π 1 = B ρ 2 B 2 ρ 1. (ii) Criterion 6), Theorem 7, page 13, should be A π 1 = 2A ρ 1B ρ 1 + A ρ 2B ρ 2 A ρ 1B ρ 2 + B ρ 1A ρ 2, B π 1 = 2B 2 ρ 1 + B 2 ρ 2 2 B ρ 2B ρ 1. 4. Midpoint criteria in terms of unisequences The RCF of D, with period-length p, has the form D = { [a0,a 1,...,a h 1,a h 1...,a 1, 2a 0 ] if p = 2h 1; [a 0,a 1,...,a h 1,a h,a h 1,...,a 1, 2a 0 ] if p = 2h. (4.1) We have Euler s midpoint formulae for solving Pell s equation x 2 Dy 2 = ±1 using the regular continued fraction (see Dickson [3, p. 358]): if p = 2h 1; Q h 1 = Q h, A 2h 2 = A h 1 B h 1 + A h 2 B h 2, B 2h 2 = B 2 h 1 + B 2 h 2, P h = P h+1, A 2h 1 = A h B h 1 + A h 1 B h 2, B 2h 1 = B h 1 (B h + B h 2 ), 7
if p = 2h. We also need the following symmetry properties from Perron [7, p. 81]: a t = a p t, t = 1, 2,...,p 1, (4.2) P t+1 = P p t, t = 0, 1,...,p 1, (4.3) Q t = Q p t, t = 0, 1,...,p. (4.4) Theorem 2. Using the notation of (4.1), in relation to Theorem 1, we have (1) If p = 2h 1,h > 1 and a h 1 > 1, or p = 1, we get criterion 3). (2) If p = 2h,h > 1 and a h 1 > 1,a h > 1, or p = 2 and a 1 > 1, we get criterion 1). (3) Suppose p = 2h and a h 1 = 1,a h > 1, so that a h is enclosed by two M-unisequences. Then (a) if M 2 is even, we get criterion 2). (b) if M is odd, we get criterion 1). (4) Suppose the centre of a period contains an M-unisequence, M 1. (a) If M is odd, then p = 2h and we get criterion 1) if M = 4t + 3, criterion 3) if M = 4t + 1. (b) If M is even, then p = 2h 1 and we get criterion 4) if M = 4t, criterion 5) if M = 4t + 2. Before we can prove Theorem 2, we need some results on the RCF to NICF-P conversion. Lemma 2. Let ξ 0 = P 0+ D Q 0 5. The RCF to NICF-P conversion and its properties have NICF-P and RCF expansions: ξ 0 = a 0 + ǫ 1 + = a a 0 + 1 +, 1 a 1 with complete quotients ξ m,ξ m, respectively. Define f(m) recursively for m 0 by f(0) = 0 and { f(m) + 1, if ǫ m+1 = 1; f(m + 1) = (5.1) f(m) + 2, if ǫ m+1 = 1. Then for m 0, { 1, if a f(m)+1 > 1; ǫ m+1 = 1, if a f(m)+1 = 1, { ξ m ξ f(m), if ǫ m = 1; = ξ f(m) + 1, if ǫ m = 1, a f(m), if ǫ m = 1 and ǫ m+1 = 1; a m = a f(m) + 1, if ǫ m ǫ m+1 = 1; a f(m) + 2, if ǫ m = 1 and ǫ m+1 = 1. Proof. See Theorem 2, Matthews and Robertson [5]. (5.2) (5.3) (5.4) Remark. By virtue of (5.1) and (5.3), we say that the ξ m are obtained from the ξ n in jumps of 1 or 2. 8
Lemma 3. Let ξ 0 = (a 0,a 1,...) be an RCF expansion. Then if [x] denotes the nearest integer to x, we have { a n, if a n+1 > 1; [ξ n ] = a n + 1, if a n+1 = 1. Proof. If [ξ n ] = a n + 1, then ξ n > a n + 1 and hence a 2 n+1 = 1, whereas if [ξ n ] = a n, then ξ n < a n + 1 and hence a 2 n+1 > 1. Lemma 4. Let ξ 0 = P 0+ D Q 0 Then have NICF-P expansion A m = ξ 0 = a 0 + ǫ 1 +. a 1 { A f(m) if ǫ m+1 = 1; A f(m)+1 if ǫ m+1 = 1, (5.5) where f(m) is defined by (5.1). Equivalently, in the notation of Bosma [2, p. 372], if n(k) = f(k + 1) 1 for k 1, then { n(k 1) + 1, if ǫ k+1 = 1; n(k) = (5.6) n(k 1) + 2, if ǫ k+1 = 1 and (5.5) has the simpler form A k = A n(k) for k 0. (5.7) Remark. From (5.2) and (5.6), we see that ǫ m+1 = 1 implies a n(m) = 1. Proof. (by induction). We first prove (5.7) for k = 0. We use Lemma 3. ǫ 1 = 1 = a 1 > 1 = [ξ 0 ] = a 0 = A 0 = A 0. ǫ 1 = 1 = a 1 = 1 = [ξ 0 ] = a 0 + 1 = a 0 a 1 + 1 = A 0 = A 1. We next prove (5.7) for k = 1. We have to prove { A A f(1) if ǫ 2 = 1; 1 = A f(1)+1 if ǫ 2 = 1, where i.e., f(1) = { 1 if ǫ 1 = 1; 2 if ǫ 1 = 1. A 1 if ǫ 1 = 1,ǫ 2 = 1; A 1 = A 2 if ǫ 1 ǫ 2 = 1; A 3 if ǫ 1 = 1,ǫ 2 = 1. 9
Now A 1 = a 0a 1 + ǫ 1. We have and Hence a 0 = { a 0 if ǫ 1 = 1; a 0 + 1 if ǫ 1 = 1 a f(1) if ǫ 1 = 1 = ǫ 2 ; a 1 = a f(1) + 1 if ǫ 1 ǫ 2 = 1; a f(1) + 2 if ǫ 1 = 1 = ǫ 2. a 1 if ǫ 1 = 1 = ǫ 2 ; a a 1 + 1 if ǫ 1 = 1,ǫ 2 = 1; 1 = a 2 + 1 if ǫ 1 = 1,ǫ 2 = 1; a 2 + 2 if ǫ 1 = 1,ǫ 2 = 1. Case 1. ǫ 1 = 1 = ǫ 2. Then A 1 = a 0 a 1 + 1 = A 1. Case 2. ǫ 1 = 1,ǫ 2 = 1. Then a 2 = 1 and A 1 = a 0 (a 1 + 1) + 1, Case 3. ǫ 1 = 1,ǫ 2 = 1. Then a 1 = 1 and A 2 = (a 0 a 1 + 1)a 2 + a 0 = a 0 a 1 + 1 + a 0 = A 1. A 1 = (a 0 + 1)(a 2 + 1) 1 = a 0 a 2 + a 0 + a 2, A 2 = (a 0 a 1 + 1)a 2 + a 0 Case 4. ǫ 1 = 1 = ǫ 2. Then a 1 = 1 = a 3 and Also = (a 0 + 1)a 2 + a 0 = A 1. A 1 = (a 0 + 1)(a 2 + 2) 1 A 3 = a 3 A 2 + A 1 = a 0 a 2 + a 2 + 2a 0 + 1. = A 2 + A 1 = ((a 0 a 1 + 1)a 2 + a 0 ) + (a 0 a 1 + 1) = ((a 0 + 1)a 2 + a 0 ) + (a 0 + 1) = A 1. Finally, let k 0 and assume (5.7) holds for k and k + 1 and use the equation A k+2 = a k+2a k+1 + ǫ k+2 A k. Then from (5.4), with j = n(k + 1) + 1, we have a j if ǫ k+2 = 1,ǫ k+3 = 1; a k+2 = a j + 1 if ǫ k+2 ǫ k+3 = 1; a j = 2 if ǫ k+2 = 1 = ǫ k+3. 10 (5.8)
Case 1. Suppose ǫ k+2 = 1 = ǫ k+3 = 1. Then n(k + 1) = n(k) + 1 = j 1, n(k + 2) = n(k + 1) + 1 = j and A k+2 = a j A j 1 + A j 2 = A j = A n(k+2). Case 2. Suppose ǫ k+2 = 1,ǫ k+3 = 1. Then n(k + 1) = n(k) + 1 = j 1, n(k + 2) = n(k + 1) + 2 = j + 1 and A k+2 = (a j + 1)A j 1 + A j 2. Now ǫ k+3 = 1 implies 1 = a n(k+2) = a j+1, so A j+1 = A j + A j 1. Hence Case 3. Suppose ǫ k+2 = 1,ǫ k+3 = 1. Then n(k + 1) = n(k) + 2 = j 1, A k+2 = A j+1 = A n(k+2). n(k + 2) = n(k + 1) + 1 = j and A k+2 = (a j + 1)A j 1 A j 3. Now ǫ k+2 = 1 implies 1 = a n(k+1) = a j 1, so A j 1 = A j 2 + A j 3. Hence Case 4. Suppose ǫ k+2 = 1 = ǫ k+3. Then A k+2 = a j A j 1 + A j 2 = A j = A n(k+2). n(k + 1) = n(k) + 2 = j 1, n(k + 2) = n(k + 1) + 2 = j + 1 and A k+2 = (a j + 2)A j 1 A j 3. Now ǫ k+3 = 1 = 1 = a n(k+2) = a j+1 and ǫ k+2 = 1 = 1 = a n(k+1) = a j 1, so Hence A j+1 = A j + A j 1 and A j 1 = A j 2 + A j 3. A k+2 = (a j + 2)A j 1 (A j 1 A j 2 ) = A j + A j 1 = A j+1 = A n(k+2). Lemma 5. Each a n > 1, n 1 will be visited by the algorithm of Lemma 2, i.e., there exists an m such that n = f(m). Proof. Let a n > 1 and f(m) n < f(m + 1). If f(m) < n, then f(m + 1) = f(m) + 2 and ǫ m+1 = 1; also n = f(m) + 1. Then from (5.2), a n = a f(m)+1 = 1. Note that in the RCF to NICF-P transformation, we have f(k) = p, where k is the NICF-P period-length. Lemma 6. Suppose that RCF partial quotients a r and a s satisfy a r > 1,a s > 1,r < s. Then the number J of jumps in the RCF to NICF-P transformation when starting from a r and finishing at a s is J = (s r + E)/2, where E is the number of even unisequences in the interval [a r,a s ]. Here we include zero unisequences [a i,a i+1 ], where a i > 1 and a i+1 > 1. 11
Proof. Suppose the unisequences in [a r,a s ] have lengths m 1,...,m N and let j i be the number of jumps occurring in a unisequence of length m i. Then { j i = m i + 1 + e i 0 if m i is odd;, where e i = 2 1 if m i is even. Then J = N j i = i=1 N i=1 m i + 1 + e i 2 = 1(N + N m 2 i ) + E 2 = s r 2 i=1 + E 2 = s r + E. 2 Corollary 3. The number of jumps in the interval [a 0,a r ], a r > 1, equals the number in the interval [a p r,a p ], where p is the period-length and r p/2. Proof. This follows from Lemma 6 and the symmetry of an RCF period. 6. Proof of Theorem 2 We use the notation of Lemmas 2 and 4. Case (1)(i). Assume p = 2h 1,h > 1 and there is an even length unisequence, or no unisequence, on each side of a h 1 > 1,a h > 1, e.g., 73 = [8, 1, 1, 5, 5, 1, 1, 16 ] or 89 = [9, 2, 3, 3, 2, 18 ]. Let f(m) = h 1, where m is the number of jumps in [a 0,a h 1 ]. Then f(m + 1) = h and ξ m = ξ h 1, ǫ m = 1, ξ m+1 = ξ h, ǫ m+1 = 1. By Corollary 3, m is also the number of jumps in [a h,a p ]. There is also one jump in [a h 1,a h ]. Hence k = 2m + 1. As Q h 1 = Q h, we have Q m = Q m+1, which is criterion 3) of Theorem 1. Also ǫ m = 1 = f(m) = f(m 1) + 1, A m 1 = A f(m 1), ǫ m+1 = 1 = f(m + 1) = f(m) + 1, A m = A f(m). Hence A m 1 = A h 2, A m = A h 1, B m 1 = B h 2, B m = B h 1 and A p 1 = A h 1 B h 1 + A h 2 B h 2 = A mb m + A m 1B m 1 = A mb m + ǫ m+1 A m 1B m 1. 12
Also B p 1 = B 2 h 1 + B 2 h 2 = B 2 m + B 2 m 1 = B 2 m + ǫ m+1 B 2 m 1. If p = 1, D = [a, 2a] and the NICF and RCF expansions are identical. Also Q 0 = Q 1 = 1,ǫ 1 = 1 and we have criterion 3). Case (1)(ii). Assume p = 2h 1, with an odd length unisequence on each side of a h 1 > 1,a h > 1, e.g., 113 = [10, 1, 1, 1, 2, 2, 1, 1, 1, 20 ]. Let f(m) = h 1. Then f(m+1) = h and ξ m = ξ h 1 + 1, ǫ m = 1, ξ m+1 = ξ h, ǫ m+1 = 1, and as in Case (1)(i), k = 2m + 1. As Q h 1 = Q h, we have Q m = Q m+1, which is criterion 3). Also ǫ m = 1 = f(m) = f(m 1) + 2, A m 1 = A f(m 1)+1, ǫ m+1 = 1 = f(m + 1) = f(m) + 1, A m = A f(m). Hence A m 1 = A h 2, A m = A h 1 and B m 1 = B h 2, B m = B h 1. Then as in Case (1)(i), we get A mb m + ǫ m+1 A m 1B m 1 = A p 1 and B 2 m + ǫ m+1 B 2 m 1 = B p 1. Case (2) Assume p = 2h,h > 1,a h 1 > 1,a h > 1, e.g., 92 = [9, 1, 1, 2, 4, 2, 1, 1, 18 ]. Let f(m) = h. Then f(m + 1) = h + 1 and ξ m = ξ h, ǫ m = 1, ξ m+1 = ξ h+1, ǫ m+1 = 1, Also by Corollary 3, m is the number of jumps in [a h,a p ]. Hence k = 2m. Then P h = P h+1 gives P m = P m+1 and we have criterion 1) of Theorem 1. Also ǫ m = 1 = f(m) = f(m 1) + 1, A m 1 = A f(m 1), ǫ m+1 = 1 = f(m + 1) = f(m) + 1, A m = A f(m). Hence A m 1 = A h 1, A m = A h and B m 1 = B h 1, B m = B h. Then A p 1 = A h B h 1 + A h 1 B h 2 = A mb m 1 + A m 1B h 2. (6.1) But B h 2 = B h a h B h 1 = B m a mb m 1 = B m 2. Hence (6.1) gives Also A p 1 = A mb m 1 + A m 1B m 2 = A mb m 1 + ǫ m A m 1B m 2. B p 1 = B h 1 (B h + B h 2 ) = B m 1(B m + B m 2). 13
Case (3)(a). Assume p = 2h, with an even length unisequence each side of a h > 1, e.g., 21 = [4, 1, 1, 2, 1, 1, 8 ]. Let f(m) = h. Then f(m + 1) = h + 2. As in Case(2), k = 2m. Also Then ξ m = ξ h, ǫ m = 1, ξ m+1 = ξ h+2 + 1, ǫ m+1 = 1. ǫ m = 1 = f(m) = f(m 1) + 1, A m 1 = A f(m 1), ǫ m+1 = 1 = f(m + 1) = f(m) + 2, A m = A f(m)+1. Hence A m 1 = A h 1, A m = A h+1 and B m 1 = B h 1, B m = B h+1. We prove criterion 2) of Theorem 1, P m+1 = P m + Q m, i.e., P h+2 + Q h+2 = P h + Q h. We note from Theorem 10.19, Rosen [8], that a h+1 = 1 implies P h+2 + P h+1 = Q h+1. Also Hence Hence We next prove P 2 h+2 = D Q h+1 Q h+2, P 2 h+1 = D Q h Q h+1. P 2 h+2 P 2 h+1 = Q h+1 (Q h Q h+2 ) = (P h+2 + P h+1 )(Q h Q h+2 ). P h+2 P h+1 = Q h Q h+2, P h+2 + Q h+2 = P h+1 + Q h = P h + Q h (6.2) A p 1 = B m 1(A m A m 1) + A m 1B m 2, (6.3) B p 1 = B m 1(B m B m 1 + B m 2). (6.4) First note that by equations (5.4), ǫ m = 1 and ǫ m+1 = 1 imply a m = a f(m) + 1 = a h + 1. Also a h+1 = 1 implies B h+1 = B h + B h 1, i.e., B m = B h + B m 1. Hence B h 2 = B h a h B h 1 Then proving (6.3). Also = (B m B m 1) (a m 1)B m 1 = B m a mb m 1 = B m 2. A p 1 = A h B h 1 + A h 1 B h 2 = (A m A m 1)B m 1 + A m 1B m 2, B p 1 = B h 1 (B h + B h 2 ) = B m 1(B m B m 1 + B m 2), 14
proving (6.4). If p = 2 and a 1 > 1, then D = a 2 + b, 1 < b < 2a,b dividing 2a (Rosen [8, p. 389]). Then D = [a, 2a/b, 2a] and the NICF and RCF expansions are identical. Then ξ 1 = a+ D,ξ b 2 = a + D,P 1 = P 2 = a,ǫ 1 = 1 and we have criterion 1). Case (3)(b). Assume p = 2h, with an odd length unisequence each side of a h > 1, e.g., 14 = [3, 1, 2, 1, 6]. Let f(m) = h. Then f(m + 1) = h + 2 and k = 2m. Then Then ξ m = ξ h + 1, ǫ m = 1, ξ m+1 = ξ h+2 + 1, ǫ m+1 = 1. ǫ m = 1 = f(m) = f(m 1) + 2, A m 1 = A f(m 1)+1, ǫ m+1 = 1 = f(m + 1) = f(m) + 2, A m = A f(m)+1. We have A m 1 = A h 1, A m = A h+1, B m 1 = B h 1, B m = B h+1. Then using (6.2), we get which is criterion 1) of Theorem 1. As ǫ m = 1, it remains to prove P m+1 = P h+2 + Q h+2 = P h + Q h = P m, A p 1 = B m 1A m A m 1B m 2 B p 1 = B m 1(B m B m 2). First, a h+1 = 1 implies A h+1 = A h + A h 1, i.e., A m = A h + A h 1. Also ǫ m = 1 = ǫ m+1 implies a m = a f(m) + 2 = a h + 2. Hence B m 2 = ǫ m B m 2 = B m a mb m 1 = (B h + B h 1 ) (a h + 2)B h 1 Hence Finally, = B h B h 1 a h B h 1 = B h 2 B h 1. B m 1A m A m 1B m 2 = B h 1 (A h + A h 1 ) A h 1 (B h 1 B h 2 ) = B h 1 A h + A h 1 B h 2 = A p 1. B m 1(B m B m 2) = B h 1 ((B h + B h 1 ) + (B h 2 B h 1 )) = B h 1 (B h + B h 2 ) = B p 1. Case (4)(a). Assume p = 2h with an M-unisequence, M odd, at the centre of a period. There are two cases: 15
M = 4t + 3, e.g., 88 = [9, 2, 1, 1, 1, 2, 18 ]. Let f(m) = h. Then f(m + 1) = h + 2 and ξ m = ξ h + 1, ǫ m = 1; ξ m+1 = ξ h+2 + 1, ǫ m+1 = 1. and as with case (3)(b), we have criterion 1) of Theorem 1. Now m is the number of jumps in [a 0,a h ]. Then we have a central unisequence [a r,a p r ] of length 4t + 3. There are t + 1 jumps of 2 in [a r,a h ], so r + 2t + 2 = h. Let J be the number of jumps in [a 0,a r ]. Hence m = J + (t + 1). There are t + 1 jumps of 2 in [a h,a p r ] and J jumps in [a p r,a p ]. Hence k = (J + t + 1) + (t + 1) + J = 2(J + t + 1) = 2m. M = 4t + 1, e.g., 91 = [9, 1, 1, 5, 1, 5, 1, 1, 18 ]. Let f(m) = h 1. Then f(m + 1) = h + 1 and ξ m+1 = ξ h+1 + 1, ǫ m+1 = 1. Also ξ m = ξ h 1 or ξ h 1 + 1. We have a central unisequence [a r,a p r ] of length 4t + 1. There are t jumps of 2 in [a r,a h 1 ], so r + 2t = h 1. Let J be the number of jumps in [a 0,a r ]. Hence m, being the number of jumps in [a 0,a h 1 ] satisfies m = J +t. There is also one jump in [a h 1,a h+1 ], t jumps of 2 in [a h+1,a p r ] and J jumps in [a p r,a p ]. Hence k = (J + t) + 1 + t + J = 2(J + t) + 1 = 2m + 1. Then Q m+1 = Q h+1 and Q m = Q h 1, so Q h 1 = Q h+1 implies Q m = Q m+1 and we have criterion 3) of Theorem 1. We have A m = A f(m)+1 = A h. Also, regardless of the sign of ǫ m, we have A m 1 = A h 2. We now prove A k 1 = A mb m A m 1B m 1, (6.5) B k 1 = B 2 m B 2 m 1. (6.6) Noting that a h = 1 gives A h = A h 1 + A h 2 and B h = B h 1 + B h 2, we have A mb m A m 1B m 1 = A h B h A h 2 B h 2 = A h (B h 1 + B h 2 ) (A h A h 1 )B h 2 Also = A h B h 1 + A h 1 B h 2 = A p 1. B 2 m B 2 m 1 = B 2 h B 2 h 2 = (B h B h 2 )(B h + B h 2 ) = B h 1 (B h + B h 2 ) = B p 1. Case (4)(b) Assume p = 2h 1 with an M-unisequence, M even, at the centre of a period. There are two cases: M = 4t, e.g., 13 = [3, 1, 1, 1, 1, 6 ]. Let f(m) = h 1. Then f(m + 1) = h + 1 and ξ m = ξ h 1 + 1, ǫ m = 1, ξ m+1 = ξ h+1 + 1, ǫ m+1 = 1. 16
We have a central unisequence [a r,a p r ] of length 4t with r + 2t = h 1. Let J be the number of jumps in [a 0,a r ]. There are t jumps of 2 in [a r,a h 1 ]. Hence m, being the number of jumps in [a 0,a h 1 ] satisfies m = J + t. There are also t jumps of 2 in [a h 1,a p r 1 ], one jump in [a p r 1,a p r ] and J jumps in [a p r,a p ]. Hence Then k = (J + t) + t + 1 + J = 2(J + t) + 1 = 2m + 1. ǫ m = 1 = f(m) = f(m 1) + 2, A m 1 = A f(m 1)+1, ǫ m+1 = 1 = f(m + 1) = f(m) + 2, A m = A f(m)+1. We have A m 1 = A h 2, A m = A h. We now verify criterion 4) of Theorem 1. We note that a h = 1 implies P h+1 = Q h P h. Then P m+1 = Q m + 1 2 Q m+1. (6.7) Also Hence (6.7) holds if and only if However Next we prove Let P m+1 = P h+1 + Q h+1 = Q h P h + Q h+1. Q m + 1 2 Q m+1 = Q h 1 + 1 2 Q h+1. Q h P h + Q h+1 = Q h 1 + 1 2 Q h+1, i.e., Q h 1 P h + Q h+1 = Q h 1 + 1 2 Q h+1, i.e., P h = 1 2 Q h+1. P 2 h = D Q h 1 Q h, P 2 h+1 = D Q h Q h+1, P 2 h P 2 h+1 = Q h (Q h+1 Q h 1 ), P h P h+1 = Q h+1 Q h 1, P h (Q h P h ) = Q h+1 Q h, 2P h = Q h+1. A p 1 = A mb m + 2A m 1B m 1 (A mb m 1 + B ma m 1), (6.8) B p 1 = B 2 m + 2B 2 m 1 2B mb m 1. (6.9) T = A mb m + 2A m 1B m 1 (A mb m 1 + B ma m 1). 17
Then T = A h B h + 2A h 2 B h 2 (A h B h 2 + B h A h 2 ) = A h (B h B h 2 ) + A h 2 (B h 2 B h ) + A h 2 B h 2 = A h B h 1 A h 2 B h 1 + A h 2 B h 2 = A h B h 1 + A h 2 (B h 2 B h 1 ) = (A h 1 + A h 2 )B h 1 + A h 2 (B h 2 B h 1 ) = A h 1 B h 1 + A h 2 B h 2 = A p 1. Also B 2 m + 2B 2 m 1 2B mb m 1 = B 2 h + 2B 2 h 2 2B h B h 2 = B h (B h 2B h 2 ) + 2B 2 h 2 = (B h 1 + B h 2 )(B h 1 B h 2 ) + 2B 2 h 2 = B 2 h 1 B 2 h 2 + 2B 2 h 2 = B 2 h 1 + B 2 h 2 = B p 1. M = 4t+2, e.g., 29 = [5, 2, 1, 1, 2, 10 ]. Let f(m) = h. Then ǫ m = 1 and ξ m = ξ h +1. Also f(m) = f(m 1) + 2, so A m 1 = A f(m 1)+1 = A h 1. Then we have a central unisequence [a r,a p r ] of length 4t + 2. There are t + 1 jumps in [a r,a h ], so r + 2t + 2 = h. Let J be the number of jumps in [a 0,a r ]. Hence m, being the number of jumps in [a 0,a h ] satisfies m = J + t + 1. There are also t jumps of 2 in [a h,a p r 1 ], one jump in [a p r 1,a p r ] and J jumps in [a p r,a p ]. Hence k = (J + t + 1) + t + 1 + J = 2(J + t + 1) = 2m. We now verify Case 5) of the midpoint criteria: Then, as ξ m 1 = ξ h 2 or ξ h 2 + 1, we have Q m 1 = Q h 2 and P m = Q m + 1 2 Q m 1. (6.10) P m = Q m + 1 2 Q m 1 P h + Q h = Q h + 1 2 Q h 2 P h = 1 2 Q h 2. But a h 1 = 1 implies P h = Q h 1 P h 1. Hence P 2 h 1 P 2 h = (D Q h 2 Q h 1 ) (D Q h 1 Q h ), (P h 1 P h )Q h 1 = Q h 1 (Q h Q h 2 ), P h 1 P h = Q h Q h 2, Q h 1 2P h = Q h 1 Q h 2, 2P h = Q h 2. 18
Next we prove A p 1 = 2A m 1B m 1 + A m 2B m 2 (A m 1B m 2 + B m 1A m 2), (6.11) B p 1 = 2B 2 m 1 + B 2 m 2 2B m 1B m 2. (6.12) Note that regardless of the sign of ǫ m 1, we have A m 2 = A h 3. To prove (6.11), let Then Finally, we prove (6.12). T = 2A m 1B m 1 + A m 2B m 2 (A m 1B m 2 + B m 1A m 2). T = 2A h 1 B h 1 + A h 3 B h 3 (A h 1 B h 3 + B h 1 A h 3 ) = 2A h 1 B h 1 + (A h 1 A h 2 )(B h 1 B h 2 ) A h 1 (B h 1 B h 2 ) B h 1 (A h 1 A h 2 ) = A h 1 B h 1 + A h 2 B h 2 = A p 1. 2B 2 m 1 + B 2 m 2 2B m 1B m 2 = 2B 2 h 1 + B 2 h 3 2B h 1 B h 3 = 2B 2 h 1 + (B h 1 B h 2 ) 2 2B h 1 (B h 1 B h 2 ) This completes the proof of Theorem 2. = B 2 h 1 + B 2 h 2 = B p 1. 7. RCF periods with only odd length unisequences Lemma 7. Suppose there are no even length ( 2) unisequences in an RCF period of length p for D. If k is the NICF period-length and 0 t k/2, then f(k t) = p f(t), (7.1) Proof. Let f(t) = r. Then we have t jumps on [a 0,a r ]. Because of the symmetry of the partial quotients and the absence of even length unisequences, we get the same t jumps but in reverse order on [a p r,a p ]. There are k jumps on [a 0,a p ] and hence k t jumps on [a 0,a p r ]. Hence f(k t) = p r = p f(t). Theorem 3. Suppose there are no even length ( 2) unisequences in a RCF period of length p for D. Then if k is the NICF period-length, for 1 t k/2, we have (i) ǫ t = ǫ k+1 t ; (ii) P t = P k+1 t ; (iii) Q t = Q k t ; (iv) a t = a k t, where ξ t = P t + D is the t-th complete quotient of the NICF-P expansion of D. Q t Remark. In particular, if k = 2h, then (ii) implies P h = P h+1 and we have criterion 1) of Theorem 1; while if k = 2h + 1, then (iii) implies Q h = Q h+1 and we have criterion 3) of Theorem 1. 19
Proof. (i) We use (5.1) and Lemma 7 ǫ t = 1 f(t) = f(t 1) + 1 p f(k t) = p f(k t + 1) + 1 f(k t + 1) = f(k t) + 1 ǫ k t+1 = 1. (ii) (a) Assume ǫ t = 1. Then ǫ k+1 t = 1 and f(t) = f(t 1) + 1. Hence ξ t = ξ f(t) = P f(t)+ D Q f(t) and ξ k+1 t = ξ f(k+1 t) = ξ p f(t 1) = ξ p+1 f(t) = P p+1 f(t) + D Q p+1 f(t) = P f(t) + D Q f(t) 1. Hence P t = P f(t) = P k+1 t. (b) Assume ǫ t = 1. Then ǫ k+1 t = 1 and f(t) = f(t 1) + 2. Hence ξ t = ξ f(t) + 1 = P f(t)+q f(t) + D Q f(t) and Hence ξ k+1 t = ξ f(k+1 t) + 1 = ξ p f(t 1) + 1 = P p f(t 1) + D + 1 = P f(t 1)+1 + Q f(t 1) + D. Q p f(t 1) Q f(t 1) P t = P f(t) + Q f(t), P k+1 t = P f(t 1)+1 + Q f(t 1) = P f(t) 1 + Q f(t) 2. For brevity, write r = f(t) 1. We have to prove P t = P k+1 t, i.e., We have P r + Q r 1 = P r+1 + Q r+1. (7.2) P 2 r+1 P 2 r = (D Q r Q r+1 ) (D Q r 1 Q r ) = Q r (Q r 1 Q r+1 ). (7.3) Now ǫ t = 1 implies a f(t 1)+1 = 1 = a f(t) 1 = a r and hence P r+1 + P r = a r Q r = Q r. Then (7.3) gives P r+1 P r = Q r 1 Q r+1 and hence (7.2). (iii) To prove Q t = Q k t, we observe that ξ t = ξ f(t) or ξ f(t) + 1, ξ k t = ξ f(k t) or ξ f(k t) + 1. 20
Then (iv) Q k t = Q f(k t) = Q p f(t) = Q f(t) = Q t. a f(t) if (ǫ t,ǫ t+1 ) = (1, 1); a t = a f(t) + 1 if (ǫ t,ǫ t+1 ) = (1, 1) or ( 1, 1); a f(t) + 2 if (ǫ t,ǫ t+1 ) = ( 1, 1). a f(k t) if (ǫ k t,ǫ k t+1 ) = (1, 1); a k t = a f(k t) + 1 if (ǫ k t,ǫ k t+1 ) = (1, 1) or ( 1, 1); a f(k t) + 2 if (ǫ k t,ǫ k t+1 ) = ( 1, 1). Then as (ǫ t,ǫ t+1 ) = (ǫ k+1 t,ǫ k t ) and a f(k t) = a p f(t) = a f(t), it follows that a t = a k t. We give examples of even and odd NICF period-length in which only odd length unisequences occur. (a) 1532 = [39, 7, 9, 1, 1, 1, 3, 1, 18, 1, 3, 1, 1, 1, 9, 7, 78] Here p = 16,k = 10,P 5 = P 6. (b) = 39 + 1 + 1 7 10 1 3 1 5 1 20 1 5 1 3 1 10 + 1 7 + 1 78 277 = [16, 1, 1, 1, 4, 10, 1, 7, 2, 2, 3, 3, 2, 2, 7, 1, 10, 4, 1, 1, 1, 32 ] = 17 1 3 1 5 + 1 11 1 8 + 1 2 + 1 2 + 1 3 + 1 3 + 1 2 + 1 2 + 1 8 1 11 + 1 5 1 3 1 34. Here p = 21,k = 15,Q 7 = Q 8. 8. Acknowledgements The author thanks John Robertson and Jim White for helpful remarks on the paper of H. C. Williams. The author also thanks Alan Offer for his help with the graphics package pstricks. References [1] A. Hurwitz, Über eine besondere Art der Kettenbruch-Entwicklung reeller Grössen, Acta Math., 12 (1889), 367 405. [2] W. Bosma, Optimal continued fractions, Indag. Math. 49 (1987), 353-379. [3] L. E. Dickson, History of the Theory of Numbers, Vol. 2, Chelsea AMS reprint 1999. [4] K. R. Matthews, J. P. Robertson, J. White, Midpoint criteria for solving Pell s equation using the nearest square continued fraction, to appear in Math. Comp. [5] K. R. Matthews, J. P. Robertson, Equality of quadratic surd period-lengths for NICF and NSCF, (submitted) [6] B. Minnegerode, Über eine neue Methode, die Pellische Gleichung aufzulösen, Gött. Nachr., 23 (1873), 619 653. [7] O. Perron, Die Lehre von den Kettenbrüchen, Band 1, Teubner, 1954. [8] K. Rosen, Introduction to number theory and its applications, Addison-Wesley, 1984. 21.
[9] H. C. Williams, Some results concerning the nearest integer continued fraction expansion of D, J. Reine Angew. Math. 315, 1980, 1 15. 2000 Mathematics Subject Classification: Primary 11A55, 11Y65. Keywords: nearest integer continued fraction, period length, midpoint criteria, unisequence. 22