The Mean Number of Steps in the Euclidean Algorithm with Odd

0 downloads 0 Views 532KB Size Report
has made it possible to prove asymptotic formulas, similar to those already known for ... The algorithm with odd partial quotients is: ... log b + O(log4 log b) ... For a rational number a/b = [0;a1,...,as,1] ∈ [0,1] and a real number x ∈ [0,1], by Gauss– ...... A. V. Ustinov, “On the number of solutions of the congruence xy ≡ l(modq) ...
ISSN 0001-4346, Mathematical Notes, 2010, Vol. 88, No. 4, pp. 574–584. © Pleiades Publishing, Ltd., 2010. Original Russian Text © A. V. Ustinov, 2010, published in Matematicheskie Zametki, 2010, Vol. 88, No. 4, pp. 594–604.

The Mean Number of Steps in the Euclidean Algorithm with Odd Partial Quotients A. V. Ustinov* Khabarovsk Branch, Institute of Applied Mathematics, Russian Academy of Sciences Received April 13, 2010

Abstract—The length of the continued-fraction expansion of a rational number with odd partial quotients is expressed via the Gauss–Kuz’min statistics for the classical continued fraction. This has made it possible to prove asymptotic formulas, similar to those already known for the classical Euclidean algorithm, for the mean length of the Euclidean algorithm with odd partial quotients. DOI: 10.1134/S0001434610090300 Key words: Euclidean algorithm, Gauss–Kuz’min statistics, continued-fraction expansion, dual fraction, partial quotient.

Dedicated to the memory of A. A. Karatsuba

1. THREE FAST VERSIONS OF THE EUCLIDEAN ALGORITHM AND GAUSS–KUZ’MIN STATISTICS Three “fast” versions are usually singled out from among the different modifications of the Euclidean algorithm (see [1]); they are based on differentt methods of division with remainder: • the classical Euclidean algorithm

  a , q= b

a = bq + r,

• the algorithm with least absolute value remainder a = bq + εr,

ε = ±1,

• the algorithm with odd partial quotients a = bq + εr,

ε = ±1,

0 ≤ r < b;

 a 1 − , q= b 2 

  a − 1, q=2 2b



b b 0. In the same paper, the problem of the h was posed. l and C determination of the constants C It turns out that the question of the mean behavior of the functions l(a/b) and h(a/b) can be reduced to the analysis of the classical Euclidean algorithm if we use Gauss–Kuz’min statistics. This allows us to l prove formulas for the mean values of l(a/b) and h(a/b) similar to (4) and (5), while, for the constants C h , we can obtain representations in terms of singular series. and C For a rational number a/b = [0; a1 , . . . , as , 1] ∈ [0, 1] and a real number x ∈ [0, 1], by Gauss– Kuz’min statistics we mean the numbers (see [9])

a = #{j : 0 ≤ j ≤ s, [0; aj+1 , . . . , as , 1] ≤ x}. (6) sx b In particular, s1 (a/b) = s + 1 is the work length of the classical Euclidean algorithm applied to a pair of numbers (a, b) (here we assume that, at the first step, the variables are transposed, while, at the following steps, division with remainder occurs; see [10]). For subsequent arguments, it is convenient to extend the definition of Gauss–Kuz’min statistics to an arbitrary x > 0:

a = #{(j, t) : 0 ≤ j ≤ s, 0 ≤ t < aj , [t; aj+1 , . . . , as , 1] ≤ x} (7) sx b (here we assume that a0 = +∞). For a finite continued fraction, we have chosen the expression with 1 at the end so that the new definition (7) coincides with the old one (6) not only for x ∈ [0, 1), but also for x = 1. For the mean values of the Gauss–Kuz’min statistics, the following relations hold (the proofs from [5], [11] remain valid for an arbitrary positive x):

b 2 log(1 + x) a 1 ∗ = log b + CP (x) + O(b−1/6 log7/6+ε b), sx (8) ϕ(b) b ζ(2) a=1

b  2 log(1 + x) a 2 P (x) + O(R−1 log4 R), = log R + C sx (9) R(R + 1) b ζ(2) a=1 b≤R

where



ζ  (2) log(1 + x) 2 log(1 + x) 2γ − 2 − + log x − 1 CP (x) = ζ(2) ζ(2) 2 x2 2 (h1 (x) + h2 (x)) + , ζ(2) x+1

2 log(1 + x) ζ  (2) 1 − , CP (x) = CP (x) + ζ(2) ζ(2) 2

(10)

+

(11)

while the functions h1 (x) and h2 (x) are given by the absolutely convergent singular series n

∞  1  x − log(1 + x) , h1 (x) = n n + mx n=1 m=1

∞   1 1 − log(1 + x) . h2 (x) = n m n=1

n/x≤m 0, 1 ≤ j < h. Lemma 1. A rational number p/q can be expressed as a dual fraction if and only if p/q ∈ (ϕ − 2, ϕ); the representation by a dual fraction is unique. Proof. Necessity The necessity of the condition p/q ∈ (ϕ − 2, ϕ) follows from the inequalities       εh+1 ε2  1 −1 −1 −1 −1 , ,... , ,... < 0; ,..., < 0; , = ϕ. ϕ − 2 = 0; 3 3 ah a1 1 3 3 To prove its sufficiency, let us describe the expansion algorithm. For εh+1 = −1, we have −

p 1 = ϕ − 2 < < 0, ϕ2 q



q > ϕ2 , p

and, for some odd number ah > ϕ2 − ϕ = 1 uniquely defined, −ah − q/p will lie in the interval (ϕ − 2, ϕ). But if εh+1 = 1, then q/p > 1/ϕ and, for some odd number ah ≥ MATHEMATICAL NOTES

Vol. 88

No. 4

2010

1 1 + 2 = 1, ϕ ϕ

578

USTINOV

also uniquely defined, q/p − ah will also lie in the interval (ϕ − 2, ϕ). Thus, in each case, the pair (εh+1 , ah ) is uniquely defined; for it, εh+1 + ah > 0 and the passage to the fraction q r = ± − ah ∈ (ϕ − 2, ϕ) p p is carried out. The expansion is finite, because the height of the expanded number decreases at each step |r| + |p| < |p| + q. The uniqueness of the representation by a dual fraction is a consequence of the uniqueness of the algorithm under consideration. In what follows, the length of the dual-fraction expansion of a rational number a/b will be denoted by h (a/b). 3. CONTINUED FRACTIONS AND MATRICES A key role in the study of the statistical properties of finite continued fractions (see, for example, [5], [11]) is played by the bijection which, to each nonempty collection of natural numbers (a1 , . . . , an ) (composed of partial quotients of a rational number), assigns the matrix ⎞ ⎛ ⎞ ⎛ 0 1 0 1 ⎠···⎝ ⎠ ∈ M, ⎝ 1 as 1 a1 where  M =





 ⎠ ∈ GL2 (Z) : P ≥ 0, 1 ≤ P  ≤ Q , 1 ≤ Q ≤ Q . ⎝P Q Q P

(12)

In order to study continued fractions with odd partial quotients and the corresponding dual fractions, we introduce the mapping Φ assigning to the rational number   εh+1 ε2  a = 0; ,..., ∈ (ϕ − 2, ϕ) b ah a1 the matrix

⎛ ⎞ ⎛ ⎞

0 εh+1 ⎠ 0 ε2 ⎠ a =⎝ ···⎝ . Φ b 1 ah 1 a1

Note the main properties of the mapping Φ. 1◦ . If ⎛ ⎞

 P P a ⎠, =⎝ Φ b  Q Q then

  εh+1 ε3  0; ,..., , ah a2   εh+1 ε2  a P = 0; ,..., = , Q ah a1 b P = Q

  1 ε2 εh−1 0; , , . . . , , a1 a2 ah−1   Q 1 ε2 εh = 0; , , . . . , . Q a1 a2 ah P = P

MATHEMATICAL NOTES

(13)

Vol. 88 No. 4 2010

MEAN NUMBER OF STEPS IN THE EUCLIDEAN ALGORITHM

2◦ . Any matrix

⎛ S=⎝

P P Q Q

579

⎞ ⎠

lying in the image of the mapping Φ can be uniquely reconstructed from both the row (Q Q ) and the   column PQ . In particular, the determinant of the matrix S is a function of the ratio P  /Q ; in what follows, this function will be denoted by Δ(P  /Q ). 3◦ . The mapping Φ is a bijection between Q ∩ (ϕ − 2, ϕ) and the set of matrices ⎞ ⎛ 

   P P P P    ⎠ ∈ GL2 (Z) : 1 ≤ Q ≤ Q , P Q − P Q = Δ ,  ∈ (ϕ − 2, ϕ) . N = ⎝ Q Q Q Q 4◦ . If

⎞  P P ⎠∈N, ⎝ Q Q ⎛

then h (P  /Q ) = h(Q/Q ). 5◦ . If Q ≥ 2 and

⎛ ⎞

 ∗ P a ⎠∈M ∩N , =⎝ Φ b Q Q

then Δ((Q − P  )/Q ) = Δ(P  /Q ) and





Q

P



∗ − ⎠ =⎝ ∈M ∩N . Q − Q Q   6◦ . For Q ≥ 2, the row (Q Q ) and the column PQ can be complemented to a matrix from M in two ways. Furthermore, in each of the two pairs of resulting matrices ⎞ ⎛ ⎞ ⎛ ⎞ ⎛ ⎞ ⎛   − P P   − P P P P Q − P Q P P ⎠, ⎝ ⎠ ⎠, ⎝ ⎠, ⎝ ⎝ and Q Q Q  − Q Q Q Q Q Q Φ

b−a b

exactly one matrix lies in the set N . Property 1◦ is verified by induction. Property 2◦ immediately follows from property 1◦ . In property 3◦ , the fact that the mapping Φ is injective follows from Lemma 1 and the equality  P /Q = a/b. To prove surjectivity, consider an arbitrary matrix ⎞ ⎛  P P ⎠∈N S=⎝ Q Q and set



⎞  P P ⎠ ∈N. S = Φ(P  /Q ) = ⎝ Q Q

Then det S = det S = Δ(P  /Q ), and, for some integer t, the following relations hold: P = P + tP  , ≤ Q ; therefore, t = 0 and S = S. = Q + tQ . But 1 ≤ Q, Q Q MATHEMATICAL NOTES

Vol. 88

No. 4

2010

580

USTINOV

Property 4◦ follows from property 3◦ and relations (13). In order to prove property 5◦ , we first note that, for Q = 2, there is exactly one matrix ⎛ ⎞ 1 1 ⎠ S=⎝ 1 2 lying in M ∩ N . For it, the assertion of the lemma is obvious; therefore, we can assume that Q ≥ 3.    can be complemented to some matrix By property 2◦ , the column Q Q−P  ⎞ ⎛   ∗ Q −P ⎠∈N. S = ⎝  Q Q < Q . Here Q = Q, because Q − P  = P  . By definition (12), this matrix lies in the set M and 1 ≤ Q    = Q − Q. Hence we have it follows that QP ≡ ±QP (mod Q ), and Q Since det S = ± det S, det S ≡ P  Q ≡ det S (mod Q )

and

Δ((Q − P  )/Q ) = Δ(P  /Q ).

Property 6◦ follows from property 2◦ . 4. REDUCTION TO GAUSS–KUZ’MIN STATISTICS Lemma 2. Suppose that b ≥ 2, b/2 ≤ a < b, (a, b) = 1. Then







a a  a  b−a +h = sϕ + sϕ−1 . h b b b b Proof. Suppose that a/b = [0; 1, a1 , . . . , as , 1], (s ≥ 0). To each k between the limits 0 ≤ k ≤ s, we assign a quadruple of numbers (uk , vk , pk , qk ) defined by the equalities (uk , vk ) = (pk , qk ) = 1, pk uk = [0; ak , . . . , a1 , 1], = [0; ak+1 , . . . , as , 1]. vk qk Define the multiset (its elements may occur over and over) A = A1 ∪ A2 ∪ A3 , where A1 = {(uk , vk , pk , qk ) : 0 ≤ k ≤ s},   vk pk 1 , , < A2 = (uk , vk , pk , qk ) : 0 ≤ k ≤ s, uk ≤ 2 qk ϕ   pk 1 . < A3 = (uk , vk , pk , qk ) : 0 ≤ k ≤ s, vk ≥ 2, qk ϕ Here the multiplicity of occurrence of each quadruple in the set A is equal to the sum of the number of times this quadruple appears in A1 , A2 , and A3 . To the expansion   1 εh ε2  a = 0; , ,..., b bh bh−1 b1 and the number j between the limits 2 ≤ j ≤ h, we assign the quadruple of numbers (αj , βj , λj , μj ) specified by the conditions αj , βj , μj > 0, (αj , βj ) = (λj , βj ) = 1,     1 εj+1 εh εj ε2  λj αj = 0; , ,..., = 0; ,..., . (14) , βj bj bj+1 bh μj bj−1 b1 Let B denote the set of all such quadruples:   B = (αj , βj , λj , μj ) : 2 ≤ j ≤ h . MATHEMATICAL NOTES

Vol. 88 No. 4 2010

MEAN NUMBER OF STEPS IN THE EUCLIDEAN ALGORITHM

581

Here B = B1 ∪ B2 ∪ B3 , where

  λ B1 = (α, β, λ, μ) ∈ B : 0 < ≤ 1 , μ   λ B2 = (α, β, λ, μ) ∈ B : 1 < < ϕ , μ   λ B3 = (α, β, λ, μ) ∈ B : ϕ − 2 < < 0 . μ

2 , and B 3 denote the similar sets constructed from the dual-fraction expansion of (b − a)/b. B 1 , B Let B, By the definition of the Gauss–Kuz’min statistics,

a − 1, #(A1 ∪ A2 ) = sϕ b In addition,



a − 1, #B = h b 

#A3 = sϕ−1



a − 1. b



 b−a #B = h − 1. b

are of equal Therefore, in order to prove the lemma, it suffices to verify that the sets A and B ∪ B cardinality. To do this, let us find mappings fi , i = 1, 2, 3, that establish one-to-one correspondences i : from Ai into Bi ∪ B f1 (u, v, p, q) = (u, v, p, q), f2 (u, v, p, q) = (u, v − u, p + q, q), f3 (u, v, p, q) = (v − u, v, −p, p + q). For example, if (u, v, p, q) ∈ A1 , then, for some u and v  , ⎞⎛ ⎞ ⎛ ⎞ ⎛   ⎝u v ⎠ ⎝∗ p⎠ = ⎝∗ a⎠ , u v ∗ q ∗ b where each of the factors lies in M . If

⎞  v u ⎠∈N , ⎝ u v ⎛

then (u, v, p, q) ∈ B1 , but if

⎛ ⎝

u v 

⎞ ⎠∈ /N,

u v then

⎛ ⎝

u − u v − v  u

(see property 6◦ ),

⎛ ⎝u − u

MATHEMATICAL NOTES

Vol. 88

u

v− v

No. 4

v

⎞ ⎠∈N

v ⎞⎛ ⎞ ⎛ ⎞ ⎠ ⎝∗ p⎠ = ⎝∗ b − a⎠ , ∗ q ∗ b

2010

582

USTINOV

1 . Moreover, each quadruple (α, β, λ, μ) ∈ B1 ∪ B 1 will lie in the image of f1 . Thus, and (u, v, p, q) ∈ B if (α, β, λ, μ) ∈ B1 , then (the factors lie in N ) ⎞⎛ ⎞ ⎛ ⎞ ⎛   ⎝α β ⎠ ⎝∗ λ⎠ = ⎝∗ a⎠ . α β ∗ μ ∗ b The first factor also lies in the set M , and the matrices ⎛ ⎞ ∗ λ ⎝ ⎠ and ∗ μ



⎞ ∗ a ⎝ ⎠ ∗ b

can be transformed into matrices from M by changing the first columns (see property 6◦ ). Hence (α, β, λ, μ) ∈ A1 . 1 , then But if (α, β, λ, μ) ∈ B ⎛ ⎞⎛ ⎞ ⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎛ ⎞  β  β − β α ∗ λ ∗ b − a α − α ∗ λ ∗ a ⎝ ⎠⎝ ⎠=⎝ ⎠, ⎝ ⎠⎝ ⎠=⎝ ⎠. α β ∗ μ ∗ b α β ∗ μ ∗ b In the last equality, each of the factors (perhaps, after replacing the elements marked by an asterisk) will lie in M , and hence, also in this case, (α, β, λ, μ) ∈ A1 . The fact that f2 and f3 are bijective is verified in a similar way from the equalities ⎞⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎛         ⎝u v ⎠ ⎝p p⎠ = ⎝u v − u ⎠ ⎝p + q p + q⎠ , u v u v−u q q q q ⎞⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎛        −p ⎠ ⎝u v ⎠ ⎝p p⎠ = ⎝v − u v ⎠ ⎝ −p , u v v−u v q q p + q  p + q which allow transforming the products of matrices from M into the products of matrices from the set N , and conversely. Example. For the fraction 5/7 = [0; 1, 2, 1, 1], the sets A1 , A2 , and A3 are of the form A1 = {(1, 1, 2, 5), (1, 3, 1, 2), (3, 4, 1, 1)},

A2 = A3 = {(1, 3, 1, 2)}.

The elements of A1 are in one-to-one correspondence with the decompositions of the matrix ⎛ ⎞ 3 5 ⎝ ⎠ = Ψ(1, 2, 1, 1) 4 7 into the product of the elements of M : ⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎝3 5⎠ = ⎝0 1⎠ ⎝1 2⎠ = ⎝1 2⎠ ⎝1 1⎠ = ⎝2 3⎠ ⎝0 1⎠ . 4 7 1 1 3 5 1 3 1 2 3 4 1 1 From the expansion 5/7 = 0; 1/1, 1/1, 1/1, −1/3 we find the set B = {(1, 1, 2, 5), (1, 2, 3, 2), (2, 3, −1, 3)}, whose elements correspond to the decompositions of the matrix ⎛ ⎞

⎝2 5⎠ = Φ 5 7 3 7 MATHEMATICAL NOTES

Vol. 88 No. 4 2010

MEAN NUMBER OF STEPS IN THE EUCLIDEAN ALGORITHM

into the product of the matrices from N : ⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎛ ⎞⎛ ⎞ 2 5 0 1 1 2 1 1 1 3 1 2 0 −1 ⎝ ⎠=⎝ ⎠⎝ ⎠=⎝ ⎠⎝ ⎠=⎝ ⎠⎝ ⎠. 3 7 1 1 2 5 1 2 1 2 2 3 1 3 Here B1 = {(1, 1, 2, 5)},

B2 = {(1, 2, 3, 2)},

B3 = {(2, 3, −1, 3)}.

Similarly, from the fraction 2/7 = 0; 1/3, 1/1, 1/1 , we construct the set = {(1, 3, 1, 2), (3, 4, 1, 1)}, B whose elements correspond to the decomposition of the matrix ⎛ ⎞

⎝1 2⎠ = Φ 2 7 3 7 into the product of matrices from N : ⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎛ ⎞⎛ ⎞ ⎝1 2⎠ = ⎝0 1⎠ ⎝1 1⎠ = ⎝1 1⎠ ⎝0 1⎠ . 3 7 1 3 1 2 3 4 1 1 Here 1 = {(1, 3, 1, 2), (3, 4, 1, 1)}, B

2 = B 3 = ∅. B

i , i = 1, 2, 3. We can easily see that fi (Ai ) = Bi ∪ B 5. MAIN RESULTS Lemma 3. Suppose that b ≥ 2, (a, b) = 1, 1 ≤ a, a < b, aa ≡ 1 (mod b). Then







a b − a  a  b−a +h =h +h . h b b b b Proof. Complementing the columns ⎛

a b

and

 b−a  b

⎞ ∗ a ⎠, ⎝ b − a b

for Δ(a/b) = 1 and the matrices

⎞ ∗ a ⎠, ⎝  a b ⎛

to matrices from N , we obtain the matrices ⎛ ⎞ ∗ b−a ⎝ ⎠ a b



⎞ ∗ b−a ⎝ ⎠  b−a b

for Δ(a/b) = −1. In each case, the assertion of the lemma follows from property 4◦ . Proof of the theorem. Using Lemmas 2 and 3, we obtain   

b b b  ∗ ∗ ∗  a a a = = h h h b b b a=1 a=1 a=1





∗ a

∗ a  a  b−a +h = + sϕ−1 . h sϕ = b b b b b/2≤a≤b

MATHEMATICAL NOTES

Vol. 88

b/2≤a≤b

No. 4

2010

583

584

USTINOV

If a/b = [0; 1, a1 , a2 , . . . , as , 1], then (b − a)/b = [0; a1 + 1, a2 , . . . , as , 1]. Therefore, by the definition of the Gauss–Kuz’min statistics, we have









a b−a a b−a b−a a sx − sx = χ[0,{x}] + χ[0,x] − χ[0,{x}] − χ[0,x] , b b b b b b−a where χI is the characteristic function of the interval I. In particular,







a b−a a b−a = sϕ , sϕ−1 = sϕ−1 . sϕ b b b b Hence





b b

 ∗ 1 ∗ a a a = + sϕ−1 h sϕ b 2 b b a=1

and, therefore,  1≤a≤b

a=1







1  a a a = + sϕ−1 . h sϕ b 2 b b 1≤a≤b

Using relations (8) and (9), we obtain the assertion of the theorem. ACKNOWLEDGMENTS This work was supported by the Presidential grant no. MD-2339.2010.1, by the Dynasty Foundation, by the Russian Foundation for Basic Research (grants no. 09-01-12129-ofi-m, no. 10-01-98001-rsibir’-a, and no. 09-01-00371-a), as well as by the DVO grant no. 09-I-P4-03. REFERENCES ´ “Dynamical analysis of the class of Euclidean algorithms,” Theoret. Comput. Sci. 297 (1-3), 447– 1. B. Vallee, 486 (2003). 2. H. Heilbronn, “On the average length of the class of finite continued fractions,” in Number Theory and Analysis, Papers in Honor of Edmund Landau (Plenum, New York, 1969), pp. 87–96. 3. J. W. Porter, “On a theorem of Heilbronn,” Mathematika 22 (1), 20–28 (1975). 4. D. E. Knuth, “Evaluation of Porter’s constant,” Comput. Math. Appl. 2 (2), 137–139 (1976). 5. A. V. Ustinov, “Asymptotic behaviour of the first and second moments for the number of steps in the Euclidean algorithm,” Izv. Ross. Akad. Nauk Ser. Mat. 72 (5), 189–224 (2008) [Russian Acad. Sci. Izv. Math. 72 (5), 1023–1059 (2008)]. ¨ 6. G. J. Rieger, “Uber die mittlere Schrittanzahl bei Divisionsalgorithmen,” Math. Nachr. 82 (1), 157–180 (1978). ¨ Kettenbruche ¨ 7. G. J. Rieger, “Ein Heilbronn–Satz fur mit ungeraden Teilnennern,” Math. Nachr. 101 (1), 295–307 (1981). ´ “Euclidean algorithms are Gaussian,” J. Number Theory 110 (2), 331–386 (2005). 8. V. Baladi and B. Vallee, 9. M. O. Avdeeva, “On the statistics of partial quotients of finite continued fractions,” Funktsional. Anal. Prilozhen. 38 (2), 1–11 (2004) [Functional Anal. Appl. 38 (2), 79–87 (2004)]. 10. Donald E. Knuth, The Art of Computer Programming, Vol. 2: Seminumerical Algorithms (AddisonWesley, Reading, Mass., 1969; Mir, Moscow, 2000). 11. A. V. Ustinov, “On the number of solutions of the congruence xy ≡ l(mod q) under the graph of a twice continuously differentiable function,” Algebra Anal. 20 (5), 186–216 (2008) [St. Petersbg. Math. J. 20 (5), 813–836 (2008)]. 12. A. V. Ustinov, “The mean number of steps in the Euclidean algorithm with least absolute value remainders,” Mat. Zametki 85 (1), 153–156 (2009) [Math. Notes 85 (1–2), 142–145 (2009)].

MATHEMATICAL NOTES

Vol. 88 No. 4 2010

Suggest Documents