35
The average length of reduced regular continued fractions This article has been downloaded from IOPscience. Please scroll down to see the full text article. 2009 Sb. Math. 200 1181 (http://iopscience.iop.org/1064-5616/200/8/A05) Download details: IP Address: 129.93.16.3 The article was downloaded on 09/04/2013 at 11:46 Please note that terms and conditions apply. View the table of contents for this issue, or go to the journal homepage for more Home Search Collections Journals About Contact us My IOPscience

The average length of reduced regular continued fractions

  • Upload
    elena-n

  • View
    212

  • Download
    0

Embed Size (px)

Citation preview

The average length of reduced regular continued fractions

This article has been downloaded from IOPscience. Please scroll down to see the full text article.

2009 Sb. Math. 200 1181

(http://iopscience.iop.org/1064-5616/200/8/A05)

Download details:

IP Address: 129.93.16.3

The article was downloaded on 09/04/2013 at 11:46

Please note that terms and conditions apply.

View the table of contents for this issue, or go to the journal homepage for more

Home Search Collections Journals About Contact us My IOPscience

Sbornik : Mathematics 200:8 1181–1214 c© 2009 RAS(DoM) and LMS

Matematicheskiı Sbornik 200:8 79–110 DOI 10.1070/SM2009v200n08ABEH004034

The average length of reduced regular continued fractions

E. N. Zhabitskaya

Abstract. Let l(a/b) be the number of steps of the by-excess Euclideanalgorithm applied to the numbers a and b. In this paper we obtain a three-term asymptotic formula for the expectation of the random value l(a/b),when 1 6 a 6 b 6 R and R→∞.

Bibliography: 11 titles.

Keywords: Euclidean algorithm, division by-excess, average length, con-tinued fraction.

§ 1. Introduction

A reduced regular continued fraction is, by definition, an expression of the kind

[[t0; t1, t2, . . . , tl]] = t0 −1

t1 −1

t2− . . . − 1tl

,

where the tn are integers, tn > 2 for n > 1. Every rational number r has a uniqueexpansion as a reduced regular continued fraction [[t0; t1, t2, . . . , tl]], where t0 = dre(the ceiling of r) and tn > 2 for n > 1. Basic properties of these fractions aregiven in Perron’s book [1], Ch. I; see also Finkel’shtein [2]. Given a number r,let l(r) be the length of the reduced regular continued fraction [[t0; t1, t2, . . . , tl]]representing r.

In this paper we obtain a three-term asymptotic formula with power-law fall-offin the error term for the average length E(R) over all reduced regular continuedfractions for numbers a/b, where a, b ∈ N, a 6 b 6 R, and R > 2 is a real number.Let

N(R) =∑b6R

∑a6b

l

(a

b

).

Then

E(R) =2N(R)

[R]([R] + 1)

is said to be the average length.

This research was carried out with the financial support of the Russian Foundation for BasicResearch (grant no. 09-01-00371-a).

AMS 2000 Mathematics Subject Classification. Primary 11A55; Secondary 11K50.

1182 E. N. Zhabitskaya

Theorem 1 (the main result). The following asymptotic formula holds as R →∞:

E(R) =1

2ζ(2)log2 R +

1ζ(2)

(2γ − 3

2− ζ ′(2)

ζ(2)

)log R

+1

ζ(2)

(2γ2 − 3γ +

74− ζ ′(2)

ζ(2)

(2γ − 3

2

)+

2(ζ ′(2))2 − ζ ′′(2)ζ(2)2ζ2(2)

)+ O(R−1 log5 R);

here ζ(s) is the Riemann zeta-function and γ is the Euler constant.

The coefficients in the asymptotic formula have the following approximate num-erical values: log2 R has coefficient 0.3039, log R has coefficient 0.1364, and 0.1264is the coefficient of one.

We may also consider the sum

N∗(R) =∑b6R

∑a6b

(a,b)=1

l

(a

b

)

of the lengths of reduced regular continued fractions taken only over coprime aand b, and correspondingly, the average length E∗(R) of such fractions. Then eachreduced regular continued fraction of a rational number not exceeding 1 whosedenominator does not exceed R will be counted exactly once.

Corollary 1. The following asymptotic formula holds as R →∞:

E∗(R) =1

2ζ(2)log2 R +

1ζ(2)

(2γ − 3

2− 2

ζ ′(2)ζ(2)

)log R

+1

ζ(2)

(2γ2 − 3γ +

74− 2

ζ ′(2)ζ(2)

(2γ − 3

2

)+

3(ζ ′(2))2 − ζ ′′(2)ζ(2)ζ2(2)

)+ O(R−1 log6 R). (1)

The question how the average length of ordinary continued fractions behaveswas first treated by Heilbronn in [3]. In 1968 he identified the principal term of theasymptotics for the average length, the average being taken over numerators. Forthe same average, an asymptotic formula with two significant terms was obtainedlater by Porter [4]. Considering averages over both numerators and denominators,an asymptotic formula with power-law fall-off in the error term was obtained byVallee [5] through the use of probability and ergodic methods. The most recentdevelopment in this field is due to Ustinov [6], who obtained an asymptotic formulawith better fall-off in the error term than the one that can be derived from Porter’sresult.

The length of the ordinary continued fraction for a number a/b is equal to thenumber of steps of the Euclidean algorithm applied to numbers a and b. Similarly,l(a/b) may be looked upon as the number of steps of the by-excess Euclideanalgorithm. In this regard, E(R) is the expectation of the number of steps of theby-excess Euclidean algorithm applied to a and b, when a and b range betweenthe bounds

1 6 a 6 b 6 R, R →∞.

The average length of a reduced regular continued fraction 1183

In 2003, in [7], while examining the statistical properties of different variationsof the Euclidean algorithm by means of probability and ergodic methods, Valleeobtained, in particular, the leading term of the asymptotic formula for the expec-tation of the number of steps of the by-excess Euclidean algorithm (and hence forthe average length over reduced regular continued fractions). In this paper we usean approach suggested by Ustinov in [6] and obtain a stronger result than Vallee’s(Theorem 5 in [7]).

§ 2. Reducing the problem to finding the numberof solutions of a system of inequalities

2.1. Elementary properties of convergents. Let r be a rational number, andlet [[t0; t1, t2, . . . , tl]] be its development into a reduced regular continued fraction.Given an n 6 l, the continued fraction pn/qn = [[t0; t1, t2, . . . , tn]] is called the nthconvergent of the continued fraction for r; here (pn, qn) = 1.

The following properties of convergents are immediate, and can be easily verifiedby induction on k (also they may be found in [1], Ch. I).

Property 1. Let k, 1 < k 6 l, be an integer. Then{pk = akpk−1 − pk−2,

qk = akqk−1 − qk−2.

So that these formulae also hold for k = 1 we set

p−1 = 1, q−1 = 0.

Property 2. Let 0 6 k 6 l be an integer. Then

pkqk−1 − qkpk−1 = −1.

Property 3. Let 0 6 k 6 l be an integer. Then

pk

qk<

pk−1

qk−1.

Property 4. Let 0 6 k 6 l be an integer. Then

qk > qk−1.

Property 5. Let 0 6 k 6 l be an integer. Then

pk − αqk

pk−1 − αqk−1= ak −

1

ak−1 −1

ak−2− . . . −1

a0 − α

.

Property 6. Let 0 6 k 6 l be an integer. Then

pk − αqk < pk−1 − αqk−1.

1184 E. N. Zhabitskaya

2.2. A lemma to characterize a pair of convergents.

Lemma 1. Let α ∈ (0, 1) be a real number, and let P , P ′, Q′, Q be positiveintegers, with Q < Q′. Then the following two conditions are equivalent :

1) P/Q and P ′/Q′ are successive convergents for the reduced regular continuedfraction for α, both different from this number;

2) PQ′ − P ′Q = 1 and 0 < (P ′ − αQ′)/(P − αQ) < 1.

Proof. Assume that 1) holds. Then the statements

PQ′ − P ′Q = 1,

α <P ′

Q′ <P

Q=⇒ P ′ − αQ′

P − αQ> 0,

0 < P ′ − αQ′ < P − αQ =⇒ P ′ − αQ′

P − αQ< 1

can all easily be derived from the properties of convergents. This gives 2).Assuming 2), we express P ′/Q′ as a reduced regular continued fraction

P ′

Q′ = [[t0; t1, . . . , tk+1]],

and consider its kth convergent

P ′′

Q′′ = [[t0; t1, . . . , tk]].

For the fractions P ′/Q′ and P ′′/Q′′, we have

P ′′Q′ − P ′Q′′ = 1, Q′′ < Q′.

We claim that, by the hypothesis of the lemma, P ′′, Q′′ coincide with P , Q. Sup-pose, on the contrary, that

PQ′ − P ′Q = 1 and Q < Q′

for some integers P and Q different from P ′′ and Q′′. Then

Q′(P − P ′′)− P ′(Q−Q′′) = 0,

and henceQ′

P ′ =Q−Q′′

P − P ′′ .

The fraction on the left is irreducible and so

Q−Q′′ = kQ′, P − P ′′ = kP ′,

where k is an integer. Hence

−Q′ < Q−Q′′ = kQ′ < Q′ =⇒ k = 0 =⇒ P = P ′′, Q = Q′′,

giving a contradiction.

The average length of a reduced regular continued fraction 1185

Since 0 < (P ′ − αQ′)/(P − αQ) < 1, from Property 5 we have

0 <P ′ − αQ′

P − αQ= tk+1 −

1

tk −1

tk−1− . . . −1

t0 − α

< 1.

As ti > 2 for i = 1, . . . , k + 1, it follows that

0 < tk −1

tk−1 −1

tk−2− . . . −1

t0 − α

< 1,

. . . . . . . . . . . . . . . . . . . . . . . . . . .

0 < t0 − α < 1.

This implies

0 < t0 − α < 1 =⇒ t0 = dαe = 1,

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

0 < tk+1 −1

tk −1

tk−1− . . . −1

t0 − α

< 1 =⇒ tk+1 =

1

tk −1

tk−1− . . . −1

t0 − α

.

Consequently,α = [[1; t1, . . . , tk+1, α

′]].This completes the proof of Lemma 1.

2.3. On the number of solutions of the system. Let T (R) be the number ofsolutions of the system

PQ′ − P ′Q = 1,

nP ′ −mP = a, nQ′ −mQ = b,

1 6 P ′ 6 Q′, 1 6 P 6 Q, Q < Q′,

0 < m < n, 1 6 a < b 6 R.

(2)

Lemma 2. The sum of the lengths of the reduced regular continued fractions forthe numbers a/b, 1 6 a 6 b 6 R, is as follows :

N(R) = T (R) +R2

2+ O(R). (3)

Proof. Consider a number a/b, 1 6 a < b 6 R. By Lemma 1 a necessary andsufficient condition that a quadruple P , P ′, Q, Q′ be an integer solution of thesystem

PQ′ − P ′Q = 1,

0 <aQ′ − bP ′

aQ− bP< 1,

1 6 P ′ 6 Q′, 1 6 P 6 Q, Q < Q′,

(4)

1186 E. N. Zhabitskaya

is that P/Q and P ′/Q′ are successive convergents to a/b, both different from a/b.There are l(a/b)− 1 such pairs, so

l

(a

b

)= 1 + m(a, b), (5)

where m(a, b) is the number of solutions of (4).Further, PQ′ − P ′Q = 1, and hence corresponding to a and b there is a unique

pair of integers m and n such that

nP ′ −mP = a and nQ′ −mQ = b.

Therefore, the number of solutions of the system (4) with respect to P , P ′, Q, Q′

coincides with the number of solutions of the system

PQ′ − P ′Q = 1,

0 <aQ′ − bP ′

aQ− bP< 1,

nP ′ −mP = a, nQ′ −mQ = b,

1 6 P ′ 6 Q′, 1 6 P 6 Q, Q < Q′,

(6)

with respect to P , P ′, Q, Q′, m, n. Now

aQ′ − bP ′

aQ− bP=

m

n,

and so the inequality 0 < (aQ′ − bP ′)/(aQ − bP ) < 1 in (6) is equivalent to theinequality 0 < m/n < 1; that is, either 0 < m < n or n < m < 0. If n < m < 0,then, since Q < Q′, we have

b = nQ′ −mQ < 0.

But this contradicts the choice of b. Therefore, 0 < m < n, so the system (6) isequivalent to

PQ′ − P ′Q = 1,

nP ′ −mP = a, nQ′ −mQ = b,

1 6 P ′ 6 Q′, 1 6 P 6 Q, Q < Q′,

0 < m < n.

(7)

Thus, m(a, b) coincides with the number of solutions of (7).Summing the left- and right-hand sides of (5) over the (a, b) inside the triangle

{(a, b) : 1 6 a < b 6 R} separately gives the required equality (3). This completesthe proof of Lemma 2.

We now show that the number of solutions of the system (2) is the same as forthe system

nQ′ −mQ 6 R,

1 6 Q < Q′, (Q,Q′) = 1.

0 < m < n.

(8)

It is readily seen that to any octuple {P, P ′, Q,Q′,m, n, a, b} of solutions of the sys-tem (2) there corresponds a quadruple {Q, Q′,m, n} of solutions of (8). Conversely,

The average length of a reduced regular continued fraction 1187

any quadruple {Q,Q′,m, n} yields a unique octuple {P, P ′, Q,Q′,m, n, a, b} of solu-tions of (2), inasmuch as the numbers P , P ′ are completely determined by Q, Q′

from the equality PQ′−P ′Q = 1 and the inequalities 1 6 P ′ 6 Q′ and 1 6 P 6 Q;moreover, the inequality −mP + nP ′ < −mQ + nQ′ holds and the numbers a, bare uniquely determined in terms of P , P ′, Q, Q′, m and n.

The change of variables k = n − m and Q′′ = Q′ − Q transforms (8) into theform

nQ′′ + kQ 6 R,

1 6 Q, 1 6 Q′′, (Q,Q′′) = 1,

1 6 k < n.

(9)

Thus, T (R) coincides with the number of solutions of (9).

§ 3. Auxiliary results

To prove Theorem 1 we require the following facts.

Lemma 3. Let f(x) be a twice continuously differentiable function on an interval[a, b], and let ρ(x) and σ(x) be the functions defined as follows :

ρ(x) =12− {x} and σ(x) =

∫ x

0

ρ(t) dt.

Then ∑a<x6b

f(x) =∫ b

a

f(x) dx + ρ(b)f(b)− ρ(a)f(a) + σ(a)f ′(a)

− σ(b)f ′(b) +∫ b

a

σ(x)f ′′(x) dx, (10)

where the summation is taken over integers x.

A proof of this result may be found in [8], Theorem 1.

Corollary 2. The following formulae hold :∑a<Q6b

1 = b− a + ρ(b)− ρ(a), (11)

∑a<Q6b

Q =b2

2− a2

2+ bρ(b)− aρ(a) + O(1), (12)

∑Q6U

1Q2

= ζ(2)− 1U

+ O

(1

U2

), (13)

∑Q6U

1Q

= log U + γ +ρ(U)U

+ O

(1

U2

), (14)

∑Q6U/2

1U −Q

= log 2 + O

(1U

), (15)

1188 E. N. Zhabitskaya

∑Q6U

log Q

Q=

log2 U

2+ γ1 + ρ(U)

log U

U+ O

(log U

U2

)(16)

(γ1 is the Stieltjes constant),∑Q6U/2

log(1−Q/U)Q

=12(log2 2− ζ(2))− 2

(U

2

)log 2 +

12U

+ O

(1

U2

). (17)

Lemma 4. Let α = p/q be a rational number in its lowerst terms, and let β, R1

and R2 be real numbers. Then∑R1<x6R2

{αx + β} =R2 −R1

2+ O

((R2 −R1

q+ 1

)s(α)

).

Here s(α) is the sum of the partial denominators of the ordinary continued fractionfor α (if α = [a0; a1, . . . , an], then s(α) = a0 + a1 + · · ·+ an).

For a proof, the reader should see [9] (§ 2, Theorem 2) for example.

Lemma 5. Given any natural number b > 2,

b∑a=1

s

(a

b

)� b log2 b.

A proof of this result may be found in [10].

Lemma 6. Let

Φ(U) =∑

Q′′6U

∑Q6Q′′

U4

2Q′′(Q′′ + Q).

Then for U > 2 the following asymptotic formula holds :

Φ(U) =U4

2log U log 2 +

U4

2

(log2 2 + γ log 2− ζ(2)

2

)+

U3

2

(ρ(U) log 2 +

14

)+ O(U2). (18)

For a proof, see [6], Lemma 8.We will now state some lemmas, which we will prove.

Lemma 7. For R > 2 the following asymptotic formulae hold :∑d6R

µ(d)d2

=1

ζ(2)+ O

(1R

),

∑d6R

µ(d) log d

d2=

ζ ′(2)ζ2(2)

+ O

(log R

R

),

∑d6R

µ(d) log2 d

d2=

2(ζ ′(2))2 − ζ ′′(2)ζ(2)ζ3(2)

+ O

(log2 R

R

);

here µ(d) is the Mobius function (that is, µ(1) = 1, µ(n) = (−1)r if n is a productof r distinct primes, and µ(n) = 0 if n is divisible by the square of a prime).

The average length of a reduced regular continued fraction 1189

Proof. Expanding 1/ζ(s) in a series (see, for example, [11])

1ζ(s)

=∞∑

d=1

µ(d)ds

and differentiating this twice with respect to s gives us

− ζ ′(s)ζ2(s)

=(

1ζ(s)

)′

s

= −∞∑

d=1

µ(d) log d

ds,

2(ζ ′(s))2 − ζ ′′(s)ζ(s)ζ3(s)

=(− ζ ′(s)

ζ2(s)

)′

s

=∞∑

d=1

µ(d) log2 d

ds.

To complete the proof of Lemma 7 it remains to set s = 2 in these equationsand evaluate the remainder in terms of the integral from R to ∞ of an integrablefunction. The proof of Lemma 7 is complete.

Corollary 3. Let Ψ(R) = aR2 log2 R + bR2 log R + cR2 + O(R logk R). Then∑d6R

Ψ(

R

d

)µ(d) =

a

ζ(2)R2 log2 R +

(b

ζ(2)− 2a

ζ ′(2)ζ2(2)

)R2 log R

+(

c

ζ(2)− b

ζ ′(2)ζ2(2)

+ a2(ζ ′(2))2 − ζ ′′(2)ζ(2)

ζ3(2)

)R2 + O(R logk+1 R).

Proof. By the definition of Ψ(R),

Ψ(

R

d

)µ(d) =

(aµ(d)d2

)R2 log2 R +

(bµ(d)d2

− 2aµ(d) log d

d2

)R2 log R

+(

cµ(d)d2

− bµ(d) log d

d2+ a

µ(d) log2 d

d2

)R2 + O

(R

dlogk R

d

),

and so it remains to sum over all d 6 R and then apply Lemma 7.

Lemma 8. For U > 2, U /∈ Z, the following asymptotic formulae hold :∑n<U

∑k<n

n+k>U

U4

2kn=

U4

4ζ(2)− U3

2+ O(U2 log U), (19)

∑n6U

∑k<n

n+k6U

U4

2nk=

∑n<U

∑k<n

n+k6U

U4

2nk=

U4

4log2 U +

U4

2γ log U +

U4

4(γ2 − 2ζ(2))

+3U3

4+

U3

2ρ(U)(log U + γ) + O(U2 log U). (20)

Proof. We will split the first sum into two parts∑n<U

∑k<n

n+k>U

U4

2kn=

∑k6U/2

∑U−k<n<U

U4

2kn+

∑U/2<k<U

∑k<n<U

U4

2kn,

1190 E. N. Zhabitskaya

and obtain an asymptotic formula for the first part. To do this we first sum withrespect to n with the help of (14), add up the corresponding terms using the factthat ρ(U −k) = ρ(U), and then put formulae (17) and (15) from Corollary 2 in theresulting expression. This gives

∑k6U/2

∑U−k<n<U

U4

2nk=

∑k6U/2

U4

2k(log U − log(U − k) +

ρ(U)U

− ρ(U − k)U − k

+ O

(1

U2

)+ O

(1

(U − k)2

))= −U4

2

∑k6U/2

log(1− k/U)k

− U3

2

∑k6U/2

ρ(U)U − k

+ O(U2 log U)

=U4

2

(ζ(2)2

− log2 22

)− U3

4− U3

2ρ(U) log 2

+ U3ρ

(U

2

)log 2 + O(U2 log U). (21)

To obtain an asymptotic formula for the second part, we proceed as above andfirst sum with respect to n with the help of (14), split the sum into terms in powersof k and log k, and apply formulae (14), (16) and (13) of Corollary 2 term-by-term.This gives

∑U/2<k<U

∑k<n<U

U4

2nk

=∑

U/2<k<U

U4

2k

(log U − log k +

ρ(U)U

− 12k

+ O

(1

U2

)+ O

(1k2

))

=(

U4

2log U +

U3

2ρ(U)

)(log 2 +

ρ(U)U

− 2U

ρ

(U

2

)+ O

(1

U2

))− U4

2

(log2 U

2− log2 U/2

2+

ρ(U)U

log U − 2U

ρ

(U

2

)log

U

2+ O

(1

U2log U

))− U4

4

(− 1

U+

2U

+ O

(1

U2

))=

U4

4log2 2− U3

4+

U3

2ρ(U) log 2− U3ρ

(U

2

)log 2 + O(U2 log U). (22)

Adding (21) and (22) together yields the required result (19).We express the second sum as the difference

∑n6U

∑k<n

n+k6U

U4

2nk=

∑n6U

∑k<n

U4

2nk−

∑n6U

∑k<n

n+k>U

U4

2nk,

The average length of a reduced regular continued fraction 1191

and obtain an asymptotic formula for the first term (here, formulae (14) and (13)of Corollary 2 will be useful). We have∑n6U

∑k<n

U4

2nk=

U4

4

((∑n6U

1n

)2

−(∑

n6U

1n2

))

=U4

4

((log U + γ +

ρ(U)U

+ O

(1

U2

))2

−(

ζ(2)− 1U

+ O

(1

U2

)))=

U4

4log2 U +

U4

2γ log U +

U4

4(γ2 − ζ(2))

+U3

4+

U3

2ρ(U)(log U + γ) + O(U2 log U). (23)

Subtracting (19) from (23) we arrive at (20). The proof of Lemma 8 is complete.

Lemma 9. For U > 2, U /∈ Z, the following asymptotic formulae hold :∑n<U

∑k<n

n+k6U

U4

2n(n + k)=

U4

2log U log 2 +

U4

2

(γ log 2− ζ(2) +

log2 22

)

+U3

2+

U3

2ρ(U) log 2 + O(U2 log U) (24)

and ∑n<U

∑k<n

n+k6U

U4

2k(n + k)

=U4

4log2 U +

U4

2log U(γ − log 2) +

U4

2

(γ2

2− γ log 2− log2 2

2

)+

U3

4+

U3

2ρ(U)(log U + γ − log 2) + O(U2 log U). (25)

Proof. We split the first sum into two parts∑n<U

∑k<n

n+k6U

U4

2n(n + k)=

∑n6U/2

∑k<n

U4

2n(n + k)+

∑U/2<n<U

∑n+k6U

U4

2n(n + k),

and find an asymptotic formula for the first sum (with the help of Lemma 6 andformula (13) of Corollary 2). We have∑

n6U/2

∑k<n

U4

2n(n + k)=

∑n6U/2

∑k6n

U4

2n(n + k)−

∑n6U/2

U4

4n2

=U4

2log

U

2log 2 +

U4

2

(log2 2 + γ log 2− ζ(2)

2

)+ U3

(U

2

)log 2 +

14

)+ O(U2)− U4

4

(ζ(2)− 2

U+ O

(1

U2

))=

U4

2log U log 2 +

U4

2(γ log 2− ζ(2)) +

3U3

4+ U3ρ

(U

2

)log 2 + O(U2). (26)

1192 E. N. Zhabitskaya

To find the asymptotic behaviour of the second sum we reduce this sum to onewe have already dealt with (see formula (22)). It follows that

∑U/2<n<U

∑n+k6U

U4

2n(n + k)=

∑U/2<n<U

∑n<t6U

U4

2nt

=U4

4log2 2− U3

4+

U3

2ρ(U) log 2− U3ρ

(U

2

)log 2 + O(U2 log U). (27)

Now adding (26) and (27) yields the required result (24).

Writing the second sum as a difference and using formulae (20) and (24) in itgives the desired result:

∑n<U

∑k<n

n+k6U

U4

2k(n + k)=

∑n<U

∑k<n

n+k6U

U4

2nk−

∑n<U

∑k<n

n+k6U

U4

2n(n + k)

=U4

4log2 U +

U4

2log U(γ − log 2) +

U4

2

(γ2

2− γ log 2− log2 2

2

)+

U3

4+

U3

2ρ(U)(log U + γ − log 2) + O(U2 log U).

The proof of Lemma 9 is complete.

Lemma 10. For U > 2, U /∈ Z, the following asymptotic formula holds :

∑n<U

∑k<n

n+k>U

U3

k= U4 log 2− U3

2(1 + log 2) + U3ρ(U) log 2 + O(U2). (28)

Proof. We split the sum in question into two parts

∑n<U

∑k<n

n+k>U

U3

k=

∑k6U/2

∑U−k<n<U

U3

k+

∑U/2<k<U

∑k<n<U

U3

k,

and find an asymptotic formula for the first part with the help of (11). We have

∑k6U/2

∑U−k<n<U

U3

k=

∑k6U/2

U3 = U3

(U

2+ ρ

(U

2

)− 1

2

)

=U4

2− U3

2+ U3ρ

(U

2

). (29)

The average length of a reduced regular continued fraction 1193

To obtain an asymptotic formula for the second sum, we invoke formulae (11)and (14). This gives

∑U/2<k<U

∑k<n<U

U3

k=

∑U/2<k<U

U3

k

(U − k + ρ(U)− 1

2

)

=(

U4 + U3ρ(U)− U3

2

)(log 2 +

ρ(U)U

− 2U

ρ

(U

2

)+ O

(1

U2

))− U3

(U

2+ ρ(U)− ρ

(U

2

))= U4 log 2− U4

2− U3 log 2

2+ U3ρ(U) log 2− U3ρ

(U

2

)+ O(U2). (30)

Adding (29) and (30) together gives (28). The proof of Lemma 10 is complete.

Lemma 11. For U > 2, U /∈ Z, the following asymptotic formula holds :

∑n<U

∑k<n

n+k>U

nU2

2k=

U4

4log 2 +

U4

8− 3U3

8+

U3

2ρ(U)

(log 2 +

12

)+ O(U2 log U). (31)

Proof. We split the sum in question into two parts

∑n<U

∑k<n

n+k>U

nU2

2k=

∑k6U/2

∑U−k<n<U

nU2

2k+

∑U/2<k<U

∑k<n<U

nU2

2k,

and obtain an asymptotic formula for the first part. To do so we use formulae(11) and (12). It follows that

∑k6U/2

∑U−k<n<U

nU2

2k

=∑

k6U/2

U2

2k

(U2

2− 1

2(U − k)2 + ρ(U)U − ρ(U)(U − k) + O(1)

)

=∑

k6U/2

(U3

2− kU2

4+

U2

2ρ(U) + O

(U2

k

))

=(

U3

2+

U2

2ρ(U)

)(U

2+ ρ

(U

2

)− 1

2

)− U2

4

(U2

8+ ρ

(U

2

)U

2+ O(1)

)+ O(U2 log U)

=7U4

32− U3

4+

U3

4ρ(U) +

3U3

(U

2

)+ O(U2 log U). (32)

To find the asymptotic behaviour of the second sum, we first take the sum withrespect to n with the help of (12), split the resulting expression into terms in powers

1194 E. N. Zhabitskaya

of k and apply formulae (14), (12) and (11). This gives

∑U/2<k<U

∑k<n<U

nU2

2k=

∑U/2<k<U

U2

2k

(U2

2− k2

2+ ρ(U)U − k

2+ O(1)

)

=∑

U/2<k<U

(U4

4k+

U3

2kρ(U)− U2k

4− U2

4+ O

(U2

k

))

=(

U4

4+

U3

2ρ(U)

)(log 2 +

ρ(U)U

− ρ

(U

2

)2U

+ O

(1

U2

))− U2

4

(3U2

8+ ρ(U)U − ρ

(U

2

)U

2+ O(1)

)− U2

4

(U

2+ O(1)

)+ O(U2 log U)

=U4

4log 2− 3U4

32− U3

8+

U3

2ρ(U) log 2− 3U3

(U

2

)+ O(U2 log U). (33)

Adding (32) and (33) gives (31). The proof of Lemma 11 is complete.

Lemma 12. For U > 2, U /∈ Z, the following asymptotic formula holds :

∑n6U

∑k<n

n+k>U

U3

n= U4(1− log 2)− U3

2log 2 + U3ρ(U)(1− log 2) + O(U2). (34)

Proof. Applying (11) and (14) for the sum in question gives

∑n6U

∑k<n

n+k>U

U3

n=

∑U/2<n6U

∑U−n<k6n−1

U3

n=

∑U/2<n6U

U3

n

(2n− U − 1

2− ρ(U)

)

=∑

U/2<n6U

(2U3 − U4

n− U3

2n− ρ(U)

U3

n

)= 2U3

(U

2+ ρ(U)− ρ

(U

2

))

−(

U4 +U3

2+ U3ρ(U)

)(log 2 +

ρ(U)U

− 2U

ρ

(U

2

)+ O

(1

U2

))= U4(1− log 2)− U3

2log 2 + U3ρ(U)(1− log 2) + O(U2),

The proof of Lemma 12 is complete.

Lemma 13. For U > 2, U /∈ Z, the following asymptotic formula holds :

∑n6U

∑k<n

n+k>U

kU2

2n=

U4

4(1− log 2)− U3

8+

U3

2ρ(U)(1− log 2) + O(U2). (35)

The average length of a reduced regular continued fraction 1195

Proof. Using (12), (14) and (11) for the sum in question gives∑n6U

∑k<n

n+k>U

kU2

2n=

∑U/2<n6U

∑U−n<k6n−1

kU2

2n

=∑

U/2<n6U

U2

2n

((n− 1)2

2− 1

2(U − n)2 +

n

2− ρ(U)(U − n) + O(1)

)

=∑

U/2<n6U

(−U4

4n+

U3

2− U2

4− U3

2nρ(U) +

U2

2ρ(U) + O(1)

)

=(−U4

4− U3

2ρ(U)

)(log 2 +

ρ(U)U

− 2U

ρ

(U

2

)+ O

(1

U2

))+

(U3

2− U2

4+

U2

2ρ(U)

)(U

2+ ρ(U)− ρ

(U

2

))=

U4

4(1− log 2)− U3

8+

U3

2ρ(U)(1− log 2) + O(U2),

which is the required result.

Lemma 14. For U > 2, U /∈ Z, the following asymptotic formula holds :∑k+Q′′<U

U4

2kQ′′ =U4

2log2 U + U4γ log U +

U4

2(γ2 − ζ(2)) +

U3

2

+ U3ρ(U)(log U + γ) + O(U2 log U). (36)

Proof. We split the sum into two parts as follows:∑k+Q′′<U

U4

2kQ′′ =∑

k<Q′′

k+Q′′<U

U4

2kQ′′ +∑

Q′′<kk+Q′′<U

U4

2kQ′′ +∑

k<U/2

U4

2k2

= 2∑

k<Q′′

k+Q′′<U

U4

2kQ′′ +∑

k<U/2

U4

2k2. (37)

By Lemma 8, the first term on the right-hand side has the following asymptoticbehaviour:∑

k<Q′′

k+Q′′<U

U4

2kQ′′ =U4

4log2 U +

U4

2γ log U +

U4

4(γ2 − 2ζ(2)) +

3U3

4

+U3

2ρ(U)(log U + γ) + O(U2 log U). (38)

We use (13) to find an asymptotic formula for the second term. This gives∑k<U/2

U4

2k2=

U4

2ζ(2)− U3 + O(U2). (39)

Adding (38) and (39) yields the required formula (36). The proof of Lemma 14 iscomplete.

1196 E. N. Zhabitskaya

§ 4. The proof of the main result

Theorem 1 (the main result). The following asymptotic formula holds as R →∞:

E(R) =1

2ζ(2)log2 R +

1ζ(2)

(2γ − 3

2− ζ ′(2)

ζ(2)

)log R

+1

ζ(2)

(2γ2 − 3γ +

74− ζ ′(2)

ζ(2)

(2γ − 3

2

)+

2(ζ ′(2))2 − ζ ′′(2)ζ(2)2ζ2(2)

)+ O(R−1 log5 R). (40)

Here ζ(s) is the Riemann zeta-function and γ is the Euler constant.

Proof. Assume (40) is true for all R which are not perfect squares. We claim thatthis formula is true for R = n2, n ∈ N. To verify this, let R1 = n2 + n−10. Bythe assumption, (40) is true for R1. Moreover, it implies the corresponding formulafor R, inasmuch as the inequalities 1 6 a 6 b 6 R and 1 6 a 6 b 6 R1 are satisfiedby the same integers a and b. Consequently, we may disregard the values R = n2

in subsequent considerations.Now applying Lemma 2 Theorem 1 follows from Theorem 2, if we take the

definition of E(R) into account.

Theorem 2. The function T (R) has the following asymptotic behaviour asR →∞:

T (R) =R2

4ζ(2)log2 R +

R2

2

(1

ζ(2)

(2γ − 3

2

)− ζ ′(2)

ζ2(2)

)log R

+R2

2

(1

ζ(2)

(2γ2 − 3γ − ζ(2) +

74

)− ζ ′(2)

ζ2(2)

(2γ − 3

2

)+

2(ζ ′(2))2 − ζ ′′(2)ζ(2)2ζ3(2)

)+ O(R log5 R). (41)

Proof. Let K(R) be the number of solutions of the systemnQ′′ + kQ 6 R,

1 6 Q, 1 6 Q′′,

1 6 k < n.

(42)

By definition, T (R) is the number of solutions of (8), so

K(R) =∑d6R

T

(R

d

),

whence

T (R) =∑d6R

µ(d)K(

R

d

)(43)

by the Mobius transformation formula. Consequently, it suffices to find K(R).

The average length of a reduced regular continued fraction 1197

To do so we introduce the parameter U =√

R. We may assume that U is notan integer (and so R is not a perfect square). Consider the following five cases:

1. Q 6 Q′′, Q′′ 6 U ;2. Q 6 Q′′, Q′′ > U ;3. Q > Q′′, Q 6 U ;4. Q > Q′′, Q > U , n 6 U ;5. Q > Q′′, Q > U , n > U .

4.1. Case 1. In this case (42) assumes the following form:

nQ′′ + kQ 6 R,

1 6 Q 6 Q′′ 6 U,

1 6 k < n.

(44)

The domain S of solutions of system (44) for various n and k and fixed Q and Q′′

is depicted in Fig. 1.

Figure 1

We want to find the number of integer points in S. To do this we express S asthe difference between the trapezoid

S1 ={

(k, n) : 0 < k 6R

Q + Q′′ , 0 < n 6 −kQ

Q′′ +R

Q′′

}

and the triangle

S2 ={

(k, n) : 0 < k 6R

Q + Q′′ , 0 < n 6 k

}.

1198 E. N. Zhabitskaya

The number of integer points in S1 is

Σ1(Q,Q′′) =[R/(Q+Q′′)]∑

k=1

[−k

Q

Q′′ +R

Q′′

]

=[R/(Q+Q′′)]∑

k=1

((−k

Q

Q′′ +R

Q′′

)−

{−k

Q

Q′′ +R

Q′′

})

=12

[R

Q+Q′′

](2

R

Q′′ −Q

Q′′ −Q

Q′′

[R

Q+Q′′

])

−W

(− Q

Q′′ ,R

Q′′ , 1,

[R

Q+Q′′

]),

where

W (α, β, R1, R2) =R2∑

x=R1

{αx + β}.

The number of integer points in the triangle S2 is

Σ2(Q, Q′′) =[R/(Q+Q′′)]∑

k=1

[k] =[R/(Q+Q′′)]∑

k=1

k =12

[R

Q + Q′′

]([R

Q + Q′′

]+ 1

).

Subtracting Σ2 from Σ1 and invoking Lemma 4 gives the number of points withinteger coordinates in the domain S as

Σ(Q, Q′′) = Σ1(Q,Q′′)− Σ2(Q,Q′′)

=R2

2Q′′(Q + Q′′)− R

2Q′′ +Q + Q′′

2Q′′

({R

Q + Q′′

}−

{R

Q + Q′′

}2)−W

(− Q

Q′′ ,R

Q′′ , 1,

[R

Q + Q′′

])=

U4

2Q′′(Q + Q′′)− U2

2Q′′ −U2

2(Q + Q′′)

+ O

(Q

Q′′

)+ O(1) + O

(((Q,Q′′)U2

Q′′(Q + Q′′)+ 1

)s

(Q

Q′′

)), (45)

where (Q, Q′′) is the greatest common divisor of Q and Q′′.To find the number of integer solutions of (44) we need to sum up Σ(Q,Q′′) over

all Q and Q′′, where Q 6 Q′′ 6 U . We shall sum the terms of each kind in (45)separately.

Applied to terms of the first kind, Lemma 6 gives∑Q′′6U

∑Q6Q′′

U4

2Q′′(Q + Q′′)=

U4

2log U log 2

+U4

2

(log2 2 + γ log 2− ζ(2)

2

)+

U3

2

(ρ(U) log 2 +

14

)+ O(U2).

The average length of a reduced regular continued fraction 1199

The sum of the terms of the second kind may be calculated directly to give

∑Q′′6U

∑Q6Q′′

U2

2Q′′ =∑

Q′′6U

U2

2=

U3

2+ O(U2).

The sum of the terms of the third kind can be found by using (14):

∑Q′′6U

∑Q6Q′′

U2

2(Q + Q′′)=

∑Q′′6U

U2

2

(log 2 + O

(1

Q′′

))

=U3

2log 2 + O(U2 log U). (46)

Now we evaluate the error term in (45). Since

O

(Q

Q′′

)6 O(1) 6 s

(Q

Q′′

)6 O

((Q′′, Q)U2

Q′′(Q′′ + Q)s

(Q

Q′′

)),

it will be sufficient to evaluate the final term in these inequalities. To do so we needLemma 5. We have∑

Q′′<U

∑Q<Q′′

O

((Q′′, Q)U2

Q′′(Q′′ + Q)s

(Q

Q′′

))6

∑d<U

∑Q′′<U

∑Q<Q′′

(Q′′,Q)=d

O

(U2d

(Q′′)2s

(Q

Q′′

))

6∑d<U

∑Q′′

1<U/d

∑Q1<Q′′

1(Q′′

1,Q1)=1

O

(U2

d(Q′′1)2

s

(Q1

Q′′1

))

6∑d<U

∑Q′′

1<U/d

O

(U2

dQ′′1

log2 Q′′1

)6

∑d<U

O

(U2

dlog3 U

)6 O(U2 log4 U).

(47)

Adding together the left- and right-hand sides separately yields the number ofsolutions in Case 1:∑

Q′′6U

∑Q6Q′′

Σ(Q,Q′′) =U4

2log U log 2 +

U4

2

(log2 2 + γ log 2− ζ(2)

2

)

+U3

2

(ρ(U) log 2− 3

4− log 2

)+ O(U2 log4 U). (48)

4.2. Case 2. In this case system (42) is as follows:nQ′′ + kQ 6 R,

1 6 Q 6 Q′′, Q′′ > U,

1 6 k < n.

(49)

Now nQ′′ + kQ 6 R and Q′′ > U , and so n < R/U = U .

1200 E. N. Zhabitskaya

Figure 2

Figure 3

Fix k and n. The domain S of solutions of system (49) with respect to Q and Q′′

is depicted in Fig. 2 (for n + k 6 U), and in Fig. 3 (for n + k > U).We will find the number of integer points in S in each of the two subcases.If n + k 6 U , then we express S as the difference between the trapezoid

S1 ={

Q,Q′′ : 0 < Q 6R

n + k, U < Q′′ 6 −Q

k

n+

R

n

}and the triangle

S2 ={

U < Q 6R

n + k, U < Q′′ < Q

}.

The number of integer points in S1 is

Σ1(k, n) =[R/(n+k)]∑

Q=1

([−Q

k

n+

R

n

]− [U ]

)

=12

[R

n + k

](−k

n

[R

n + k

]− k

n+ 2

R

n− 2[U ]

)−W

(−k

n,R

n, 1,

[R

n + k

]),

The average length of a reduced regular continued fraction 1201

and the number of integer points in S2 is

Σ2(k, n) =[R/(n+k)]∑Q=[U ]+1

(Q− 1− [U ]) =12

([R

n + k

]− [U ]− 1

)([R

n + k

]− [U ]

).

Hence, by Lemma 4, the number of points with integer coordinates in the domain Sis as follows:

Σ(k, n) = Σ1(k, n)− Σ2(k, n) =U4

2n(n + k)− U2

2n+

U2

2(n + k)− U2

2− ρ(U)U

+ O(1) + O

(k

n

)+ O

(((n, k)U2

n(n + k)+ 1

)s

(k

n

)). (50)

To sum Σ(k, n) over k and n in the domain

{(k, n) : k < n < U, n + k 6 U},

we shall sum terms of each kind in (50) separately.Applied to terms of the first kind, Lemma 9 gives

∑n<U

∑k<n

n+k6U

U4

2n(n + k)=

U4

2log U log 2 +

U4

2

(γ log 2− ζ(2) +

log2 22

)

+U3

2+

U3

2ρ(U) log 2 + O(U2 log U).

To sum the terms of the second kind we use (14) to obtain

∑n<U

∑k<n

n+k6U

U2

2n=

∑m6U

∑m/2<n<m

U2

2n=

∑m6U

U2

2

(log 2 + O

(1m

))

=U3

2log 2 + O(U2 log U).

For terms of the third kind, by direct calculation we have

∑n<U

∑k<n

n+k6U

U2

2(n + k)=

∑m6U

∑m/2<n<m

U2

2m=

∑m6U

U2

2m

(m

2+ O(1)

)

=∑

m6U

(U2

4+ O

(U2

m

))=

U3

4+ O(U2 log U), (51)

1202 E. N. Zhabitskaya

and, for terms of the fourth kind, (11) and (12) can be applied to show that∑n<U

∑k<n

n+k6U

(U2

2+ ρ(U)U

)=

(U2

2+ ρ(U)U

) ∑k<U/2

∑k<n6U−k

1

=(

U2

2+ ρ(U)U

) ∑k<U/2

(U − 2k + ρ(U)− 1

2

)

=(

U2

2+ ρ(U)U

)((U + ρ(U)− 1

2

)(U

2+ ρ

(U

2

)− 1

2

)− 2

(U2

8+

U

(U

2

)+ O(1)

))=

U4

8− 3U3

8+

U3

2ρ(U) + O(U2). (52)

Let us now evaluate the error term in (50). As before, it suffices to evaluate

O

((n, k)U2

n(n + k)s

(k

n

)).

Analogously to (47), as s(k/n) = s(n/k), we have∑n<U

∑k<n

n+k6U

O

((n, k)U2

n(n + k)s

(k

n

))6 O(U2 log4 U).

Adding together the left- and right-hand sides separately produces the followingasymptotic formula for the number of solutions of system (49) when n + k 6 U :∑

n<U

∑k<n

n+k6U

Σ(k, n) =U4

2log U log 2 +

U4

2

(γ log 2− ζ(2) +

log2 22

− 14

)

+U3

2

(94− log 2

)+

U3

2ρ(U)(log 2− 1) + O(U2 log4 U). (53)

If n + k > U , then the number of integer points in the triangle S (see Fig. 3) isas follows:

Σ(k, n) =[(R−nU)/k]∑

Q=1

([−Q

k

n+

R

n

]− [U ]

)

=12

[R−nU

k

](− k

n

[R−nU

k

]− k

n+2

R

n− 2[U ]

)−W

(−k

n,R

n, 1,

[R−nU

k

])=

U4

2kn− U3

k− U2

2n+

nU2

2k+

U

2− ρ(U)

U2 − nU

k

+ O(1) + O

(k

n

)+ O

(((n, k)(U2 − nU)

nk+ 1

)s

(k

n

)). (54)

To sum Σ(k, n) over k and n in the domain

{(k, n) : k < n < U, n + k > U},

we shall, as before, sum terms of each kind in (54) separately.

The average length of a reduced regular continued fraction 1203

Applied to terms of the first kind, Lemma 8 gives∑n<U

∑k<n

n+k>U

U4

2kn=

U4

4ζ(2)− U3

2+ O(U2 log U).

To sum the terms of the second kind we shall apply Lemma 10 to obtain∑n<U

∑k<n

n+k>U

U3

k= U4 log 2− U3

2(1 + log 2) + U3ρ(U) log 2 + O(U2).

For terms of the third kind, we have, by Lemma 12,∑n<U

∑k<n

n+k>U

U2

2n=

U3

2(1− log 2) + O(U2),

and, for terms of the fourth kind, Lemma 11 yields∑n<U

∑k<n

n+k>U

nU2

2k=

U4

4log 2 +

U4

8− 3U3

8+

U3

2ρ(U)

(log 2 +

12

)+ O(U2 log U).

A direct calculation, using (11) and (12), for terms of the fifth kind gives∑n<U

∑k<n

n+k>U

U

2=

∑U/2<n<U

∑U−n<k<n

U

2=

∑U/2<n<U

U

2(2n− U + O(1))

= U

(3U2

8+ O(U)

)− U2

2

(U

2+ O(1)

)=

U3

8+ O(U2). (55)

Using the results of our calculations of the second and fourth sums, for terms ofthe sixth kind we obtain∑n<U

∑k<n

n+k>U

ρ(U)U2 − nU

k= ρ(U)

(∑n<U

∑k<n

n+k>U

U2

k−

∑n<U

∑k<n

n+k>U

nU

k

)

= ρ(U)(

U3 log 2− U3

2log 2− U3

4

)+ O(U2) =

U3

2ρ(U)

(log 2− 1

2

)+ O(U2).

The estimate of the error term in (54) amounts to evaluating

O

((n, k)(U2 − nU)

nks

(k

n

)).

Performing the same transformations as in (47) we obtain∑n<U

∑k<n

n+k>U

O

((n, k)(U2 − nU)

nks

(k

n

))

6∑d<U

∑n1<U/d

∑k1<n1

(n1,k1)=1

O

((U2

dn1k1− U

k1

)s

(k1

n1

)).

1204 E. N. Zhabitskaya

Applying Lemma 5 and using the Abel transform (see, for example, [11] (Ch. 2, § 1,Lemma 4)) yields∣∣∣∣∑

k6n

s

(k

n

)1k

∣∣∣∣ =∣∣∣∣n log2

n−

∫ n

1

∑k6t

s

(k

n

)(− 1

t2

)dt

∣∣∣∣6 log2 n +

∑k6n

s

(k

n

) ∫ n

1

1t2

dt = O(log2 n),

and therefore∑d<U

∑n1<U/d

∑k1<n1

O

((U2

dn1− U

)1k1

s

(k1

n1

))

6∑d<U

∑n1<U/d

O

((U2

dn1− U

)log2 n1

)6

∑d<U

O

(U2

dlog3 U

)6 O(U2 log4 U).

Adding the left- and right-hand sides separately produces the following asymp-totic formula for the number of solutions of (49) when n + k > U :

∑n<U

∑k<n

n+k>U

Σ(k, n) =U4

4

(ζ(2)− 3 log 2 +

12

)

+ U3

(log 2− 3

4

)+ U3ρ(U)

(12− log 2

)+ O(U2 log4 U). (56)

Now adding (53) and (56) we obtain the number of solutions in Case 2:

∑n<U

∑k<n

Σ(k, n) =U4

2log U log 2 +

U4

2

(γ log 2− ζ(2)

2− 3

2log 2 +

log2 22

)+

U3

2

(34

+ log 2)− U3

2ρ(U) log 2 + O(U2 log4 U). (57)

4.3. Case 3. In this case (42) assumes the formnQ′′ + kQ 6 R,

1 6 Q′′ < Q 6 U,

1 6 k < n.

(58)

With fixed Q and Q′′, the set of solutions of system (58) with respect to n and kcoincides with the set of solutions of (44). Hence

Σ(Q,Q′′) =U4

2Q′′(Q + Q′′)− U2

2Q′′ −U2

2(Q + Q′′)

+ O

(Q

Q′′

)+ O(1) + O

(((Q,Q′′)U2

Q′′(Q + Q′′)+ 1

)s

(Q

Q′′

)). (59)

The average length of a reduced regular continued fraction 1205

In (59) we shall sum the terms of each kind over Q′′ < Q 6 U separately. Appliedto terms of the first kind, Lemma 6 and formula (14) give

∑Q6U

∑Q′′<Q

U4

2Q′′(Q′′ + Q)=

∑Q6U

∑Q′′<Q

(U4

2Q′′Q− U4

2Q(Q + Q′′)

)

=U4

4

( ∑Q6U

1Q

)2

− U4

2

( ∑Q6U

∑Q′′6Q

1Q(Q + Q′′)

)

=U4

4log2 U +

U4

2log U(γ − log 2) +

U4

2

(γ2

2− log2 2− γ log 2 +

ζ(2)2

)− U3

8+

U3

2ρ(U)(log U + γ − log 2) + O(U2 log U).

A direct calculation using formula (14) for terms of the second kind yields

∑Q6U

∑Q′′<Q

U2

2Q′′ =∑Q6U

U2

2

(log Q + γ + O

(1Q

))

=U2

2(U log U − U + γU + O(log U))

=U3

2log U +

U3

2(γ − 1) + O(U2 log U),

The formula for the sum of the terms of the third kind follows from (46):

∑Q6U

∑Q′′<Q

U2

2(Q + Q′′)=

U3

2log 2 + O(U2 log U).

The error term of (59) can be evaluated as above, taking the equalitys(Q/Q′′) = s(Q′′/Q) into account.

Adding the left- and right-hand sides together gives the number of solutions inCase 3:∑

Q6U

∑Q′′<Q

Σ(Q,Q′′) =U4

4log2 U +

U4

2log U(γ − log 2)

+U4

2

(γ2

2− log2 2− γ log 2 +

ζ(2)2

)− U3

2

(log U + γ − 3

4+ log 2

)+

U3

2ρ(U)(log U + γ − log 2) + O(U2 log4 U). (60)

4.4. Case 4. In this case system (42) is as follows:nQ′′ + kQ 6 R,

1 6 Q′′ < Q, Q > U,

1 6 k < n 6 U.

(61)

1206 E. N. Zhabitskaya

Figure 4

Figure 5

We proceed as in Case 2. If we fix k and n, then the domain S of solutions ofsystem (61) with respect to Q and Q′′ is as depicted in Fig. 4 (if n + k 6 U) or inFig. 5 (if n + k > U).

Let us find the number of points with integer coordinates in S in each of the twosubcases.

If n + k 6 U , then we express S as the sum of the trapezoid

S1 ={

(Q,Q′′) : U < Q 6R

n + k, 0 < Q′′ < Q

}and the triangle

S2 ={

(Q,Q′′) :R

n + k< Q 6

R

k, 0 < Q′′ 6 −Q

k

n+

R

n

}.

The number of integer points in S1 is given by the formula

Σ1(k, n) =[R/(n+k)]∑Q=[U ]+1

(Q− 1) =12

([R

n + k

]+ [U ]− 1

)([R

n + k

]− [U ]

),

The average length of a reduced regular continued fraction 1207

and the number of integer points in S2 is as follows:

Σ2(k, n) =[R/k]∑

[R/(n+k)]+1

[−Q

k

n+

R

n

]=

12

([R

k

]−

[R

n + k

])

×(−k

n

[R

k

]− k

n

[R

n + k

]− k

n+

R

n

)−W

(−k

n,R

n,

[R

n + k

],

[R

k

]).

Altogether, the number of integer points in S can be obtained from Lemma 4giving

Σ(k, n) = Σ1(k, n) + Σ2(k, n)

=U4

2k(n + k)− U2

2(n + k)− U2

2k− U2

2+ U − ρ(U)U + O(1)

+ O

(k

n

)+ O

(((n, k)

n

(U2

k− U2

n + k

)+ 1

)s

(k

n

)). (62)

To sum the Σ(k, n) over k and n in the domain{(k, n) : k < n 6 U, n + k 6 U

}we shall sum the terms of each kind in (62) separately.

Applied to terms of the first kind, formula (25) gives∑n6U

∑k<n

n+k6U

U4

2k(n + k)

=U4

4log2 U +

U4

2log U(γ − log 2) +

U4

2

(γ2

2− γ log 2− log2 2

2

)+

U3

4+

U3

2ρ(U)(log U + γ − log 2) + O(U2 log U).

The sum of the terms of the second kind has already been calculated in Case 2(see (51)), so ∑

n<U

∑k<n

n+k6U

U2

2(n + k)=

U3

4+ O(U2 log U).

The sum of the terms of the third kind can be found by formulae (11) and (14) togive ∑

n6U

∑k<n

U2

2k=

∑k<U/2

∑k<n6U−k

U2

2k=

∑k<U/2

U2

2k(U − 2k + O(1))

=U3

2

(log

U

2+ γ + O

(1U

))− U2

(U

2+ O(1)

)+ O(U2 log U)

=U3

2log U +

U3

2(γ − 1− log 2) + O(U2 log U).

1208 E. N. Zhabitskaya

Applying (52) we calculate the sum of the terms of the fourth kind:∑n6U

∑k<n

n+k6U

(−U2

2+ U − ρ(U)U

)=

(−U2

2+ U − ρ(U)U

) ∑k<U/2

∑k<n6U−k

1

=(−U2

2+ U − ρ(U)U

)(U2

4− 3U

4+

U

2ρ(U) + O(1)

)= −U4

8+

5U3

8− U3

2ρ(U) + O(U2).

The error term can be evaluated as for Case 2.Adding the left- and right-hand sides together we arrive at the following asymp-

totic formula for the number of solutions of (61) when n + k 6 U :∑n6U

∑k<n

n+k6U

Σ(k, n) =U4

4log2 U +

U4

2(γ − log 2) log U

+U4

2

(γ2

2− γ log 2− log2 2

2− 1

4

)+

U3

2

(− log U − γ +

94

+ log 2)

+U3

2ρ(U)(log U + γ − log 2− 1) + O(U2 log4 U). (63)

Next, we turn to the case n + k > U . Then the number of integer points in thedomain S can be obtained by Lemma 4 to give

Σ(k, n) =[R/k]∑

Q=[U ]+1

[−k

nQ +

R

n

]

=12

([R

k

]− [U ]

)(−k

n

[R

k

]− k

n[U ]− k

n+ 2

R

n

)−W

(−k

n,R

k, [U ],

[R

k

])=

U4

2nk− U3

n+

kU2

2n− ρ(U)

U2 − kU

n− U2

2k+

U

2

+ O

(k

n

)+ O(1) + O

(((n, k)

n

(U2

k− U

)+ 1

)s

(k

n

)). (64)

Next we sum the Σ(k, n) over k and n from the set

{(k, n) : k < n 6 U, n + k > U}.

To obtain the sum of the terms of the first kind in (64) we invoke Lemma 8, whichgives ∑

n6U

∑k<n

n+k>U

U4

2kn=

∑n<U

∑k<n

n+k>U

U4

2kn= U4 ζ(2)

4− U3

2+ O(U2 log U).

Applying Lemma 12 yields the sum of the terms of the second kind∑n6U

∑k<n

n+k>U

U3

n= U4(1− log 2)− U3

2log 2 + U3ρ(U)(1− log 2) + O(U2);

The average length of a reduced regular continued fraction 1209

the sum of terms of the third kind can be obtained from Lemma 13:∑n6U

∑k<n

n+k>U

kU2

2n=

U4

4(1− log 2)− U3

8+

U3

2ρ(U)(1− log 2) + O(U2).

The formula for the sum of the terms of the fourth kind follows from the previoustwo formulae, that is,

∑n6U

∑k<n

n+k>U

ρ(U)U2 − kU

n=

U3

2ρ(U)(1− log 2) + O(U2).

The sum of the terms of the fifth kind can be calculated by means of Lemma 10 togive ∑

n6U

∑k<n

n+k>U

U2

2k=

U3

2log 2 + O(U2).

The sum of the terms of the sixth kind has already been calculated in Case 2(see (55)):

∑n6U

∑k<n

n+k>U

U

2= U

(3U2

8+ O(U)

)− U2

2

(U

2+ O(1)

)=

U3

8+ O(U2).

The error term can be calculated as for Case 2.Adding the left- and right-hand sides together we arrive at the following asymp-

totic formula for the number of solutions of (61) when n + k > U :∑n6U

∑k<n

n+k>U

Σ(k, n)

=U4

4(ζ(2)− 3 + 3 log 2)− U3

2+ U3ρ(U)(log 2− 1) + O(U2 log4 U). (65)

If we add (63) and (65) together we obtain the following formula for the totalnumber of solutions in Case 4:∑

n6U

∑k<n

n+k6U

Σ(k, n) =U4

4log2 U +

U4

2(γ − log 2) log U

+U4

2

(γ2

2− γ log 2− log2 2

2− 7

4+

32

log 2 +ζ(2)2

)+

U3

2

(log 2− log U − γ +

54

)+

U3

2ρ(U)(log U + γ − 3 + log 2)

+ O(U2 log4 U). (66)

1210 E. N. Zhabitskaya

4.5. Case 5. In this case system (42) is as follows:nQ′′ + kQ 6 R,

1 6 Q′′ < Q, Q > U,

1 6 k < n, n > U.

(67)

Here the conditions Q′′ < Q and k < n are superfluous because they follow fromthe conditions Q > U , n > U and from the first inequality in (67).

With fixed k and Q′′, the set S of solutions of (67) with respect to n and Q isdisplayed in Fig. 6. We note that S is nonempty only when k + Q′′ < U .

Figure 6

The number of integer points in the triangle S is as follows:

Σ(k, Q′′) =[(R−kU)/Q′′]∑n=[R/U ]+1

([−n

Q′′

k+

R

k

]− [U ]

)

=12

(−Q′′

k

([R− kU

Q′′

]+

[R

U

]+ 1

)+ 2

(R

k− [U ]

))×

([R− kU

Q′′

]−

[R

U

])−W

(−Q′′

k,R

k,

[R

U

],

[R− kU

Q′′

])=

U4

2kQ′′ − U3

(1k

+1

Q′′

)+

U2

2

(Q′′

k+

k

Q′′

)+ U2

+ ρ(U)(−U2

(1k

+1

Q′′

)+ U

(k

Q′′ +Q′′

k

)+ 2U

)+ O

(Q′′

k

)+ O(1) + O

(((k, Q′′)(U2 − kU −Q′′U)

kQ′′ + 1)

s

(Q′′

k

)). (68)

It remains to sum up the Σ(k, Q′′) over all k and Q′′ such that k + Q′′ < U . Wewill treat terms of each kind in (68) separately.

The average length of a reduced regular continued fraction 1211

The sum of the terms of the first kind can be calculated by Lemma 14 to give∑k+Q′′<U

U4

2kQ′′ =U4

2log2 U + U4γ log U +

U4

2(γ2 − ζ(2)) +

U3

2

+ U3ρ(U)(log U + γ) + O(U2 log U).

Using (11), (12) and (14) we obtain the following expressions for the sums of theterms of the second, third and fourth kinds in (68):∑

k<Uk+Q′′<U

U3

(1k

+1

Q′′

)= 2

∑k<U

U3

k

(U − k + ρ(U)− 1

2

)

= 2(

U4 + U3ρ(U)− U3

2

)(log U + γ +

ρ(U)U

+ O

(1

U2

))− 2U3

(U + ρ(U)− 1

2

)= 2U4 log U + 2U4(γ − 1)

− U3(log U + γ − 1) + 2U3ρ(U)(log U + γ) + O(U2),∑k<U

k+Q′′<U

U2

2

(Q′′

k+

k

Q′′

)=

∑k<U

U2

k

((U − k)2

2+ ρ(U)(U − k) + O(1)

)

=(

U4

2+ U3ρ(U)

)(log U + γ +

ρ(U)U

+ O

(1

U2

))− (U3 + U2ρ(U))

(U + ρ(U)− 1

2

)+

U2

2

(U2

2+ ρ(U)U + O(1)

)+ O(U2 log U)

=U4

2log U +

U4

2

(γ − 3

2

)+

U3

2+ U3ρ(U)(log U + γ − 1) + O(U2 log U)

(69)

and ∑k<U

k+Q′′<U

U2 =∑k<U

U2

(U − k + ρ(U)− 1

2

)

=(

U3 + U2ρ(U)− U2

2

)(U + ρ(U)− 1

2

)− U2

(U2

2+ ρ(U)U + O(1)

)=

U4

2− U3 + U3ρ(U) + O(U2). (70)

This yields a formula for the sum of the terms of the fifth kind:∑k<U

k+Q′′<U

ρ(U)(−U2

(1k

+1

Q′′

)+ U

(k

Q′′ +Q′′

k

)+ 2U

)

= U3ρ(U)(− log U − γ +

32

)+ O(U2 log U). (71)

1212 E. N. Zhabitskaya

To evaluate the error term, first we split the corresponding sum into two parts asfollows: ∑

k+Q′′<U

O

((k, Q′′)(U2 − kU −Q′′U)

kQ′′ s

(Q′′

k

))

6∑d<U

∑k<U

∑Q′′<k

(k,Q′′)=d

O

(d(U2 − kU −Q′′U)

kQ′′ s

(Q′′

k

))

+∑d<U

∑Q′′<U

∑k<Q′′

(k,Q′′)=d

O

(d(U2 − kU −Q′′U)

kQ′′ s

(k

Q′′

)).

Each of the two sums can be evaluated similarly to the second subcase in Case 2.Adding together the left- and right-hand sides we obtain the formula for the

number of solutions in Case 5:∑k+Q′′<U

Σ(k, Q′′) =U4

2log2 U + U4

(γ − 3

2

)log U +

U4

2

(γ2 − ζ(2)− 3γ +

72

)

+ U3(log U + γ − 1) + ρ(U)(− log U − γ +

32

)+ O(U2 log4 U). (72)

4.6. The completion of the proof of Theorem 2. To find K(R) it now sufficesto add together the left- and right-hand sides of formulae (48), (57), (60), (66),and (72), which were obtained from each of the five cases considered. This gives

K(R)=U4 log2 U +U2

(2γ− 3

2

)log U +

U2

2

(2γ2− 3γ− ζ(2)+

74

)+O(U2 log4 U)

=R2

4log2 R +

R2

2

(2γ − 3

2

)log R +

R2

2

(2γ2 − 3γ − ζ(2) +

74

)+ O(R log4 R),

and so, by (43) and Corollary 3,

T (R) =∑d6R

µ(d)K(

R

d

)=

R2

4ζ(2)log2 R +

R2

2R

(1

ζ(2)

(2γ − 3

2

)− ζ ′(2)

ζ2(2)

)log R

+R2

2

(1

ζ(2)

(2γ2 − 3γ − ζ(2) +

74

)− ζ ′(2)

ζ2(2)

(2γ − 3

2

)+

2(ζ ′(2))2 − ζ ′′(2)ζ(2)2ζ3(2)

)+ O(R log5 R).

The proof of Theorem 1 is complete.

The expression for E(R) takes into account all the fractions of the kind a/b,a 6 b 6 R. Some of these will be the same; as a consequence, the lengths of somereduced regular continued fractions are counted several times. To avoid doublecounting, we may consider, instead of N(R), the sum

N∗(R) =∑b6R

∑a6b

(a,b)=1

l

(a

b

)

The average length of a reduced regular continued fraction 1213

and the corresponding average length E∗(R). We now prove the corollary statedin the introduction.

Corollary 4. The following asymptotic formula holds as R →∞:

E∗(R) =1

2ζ(2)log2 R +

1ζ(2)

(2γ − 3

2− 2

ζ ′(2)ζ(2)

)log R

+1

ζ(2)

(2γ2 − 3γ +

74− 2

ζ ′(2)ζ(2)

(2γ − 3

2

)+

3(ζ ′(2))2 − ζ ′′(2)ζ(2)ζ2(2)

)+ O(R−1 log6 R). (73)

Proof. As E∗(R) is the average length of reduced regular continued fractions forthe numbers a/b, a 6 b 6 R, (a, b) = 1, it follows that

E∗(R) = N∗(R)/(∑

b6R

∑a6b

(a,b)=1

1)

,

and now, by the Mobius transformation formula,

N∗(R) =∑d6R

µ(d)N(

R

d

),

∑b6R

∑a6b

(a,b)=1

1 =∑d6R

µ(d)∑

b6R/d

∑a6b

1 =∑d6R

µ(d)(

R2

2d2+ O

(R

d

)).

It remains to apply Corollary 3 to the last two equalities and divide one of theresulting expressions by the other. The proof of Corollary 4 is complete.

Bibliography

[1] O. Perron, Die Lehre von den Kettenbruchen. Band I. Elementare Kettenbruche, Teuber,Stuttgart 1954.

[2] Yu.Yu. Finkel’shtein, “Klein polygons and reduced regular continued fractions”, UspekhiMat. Nauk 48:3 (1993), 205–206; Englsih transl. in Russian Math. Surveys 48:3 (1993),198–200.

[3] H. Heilbronn, “On the average length of a class of finite continued fractions”, Numbertheory and analysis (papers in honor of E. Landau), Plenum, New York 1968, pp. 87–96.

[4] J. W. Porter, “On a theorem of Heilbronn”, Matematika 22:1 (1975), 20–28.

[5] B. Vallee, “A unifying framework for the analysis of a class of Euclidean algorithms”,LATIN 2000: Theoretical informatics (Punta del Este, Uruguay 2000), Lecture Notes inComput. Sci., vol. 1776, Springer-Verlag, Berlin, pp. 343–354.

[6] A.V. Ustinov, “Asymptotic behaviour of the first and second moments for the number ofsteps in the Euclidean algorithm”, Izv. Ross. Akad. Nauk Ser. Mat. 72:5 (2008), 189–224;English transl. in Izv. Math. 72:5 (2008), 1023–1059.

[7] B. Vallee, “Dynamical analysis of a class of Euclidean algorithms”, Theoret. Comput. Sci.297:1–3 (2003), 447–486.

[8] A. Karatsuba, Basic analytic number theory, Nauka, Moscow 1983; English transl.,Springer-Verlag, Berlin 1993.

[9] A.Ya. Khintchine, Selected papers in number theory, Moscow Center for ContinuousMathematical Education, Moscow 2006. (Russian)

1214 E. N. Zhabitskaya

[10] A.C. Yao and D.E. Knuth, “Analysis of the subtractive algorithm for greatest commondivisors”, Proc. Nat. Acad. Sci. U.S.A. 72:12 (1975), 4720–4722.

[11] A. I. Galochkin, Yu. V. Nesterenko and A.B. Shidlovskii, Introduction to number theory,Moscow State University Publishing House, Moscow 1984. (Russian)

E.N. Zhabitskaya

Faculty of Mechanics and Mathematics,

Moscow State University

E-mail : [email protected]

Received 21/MAY/08 and 27/MAR/09Translated by A. ALIMOV