On restricted averages of Dedekind sums

We investigate the averages of Dedekind sums over rational numbers in the set $$\mathscr{F}_\alpha(Q):=\{\, {v}/{w}\in \mathbb{Q}: 0<w\leq Q\,\}\cap [0, \alpha)$$ for fixed $\alpha\leq 1/2$. In previous work, we obtained asymptotics for $\alpha=1/2$, confirming a conjecture of Ito in a quantitative form. In the present article we extend our former results, first to all fixed rational $\alpha$ and then to almost all irrational $\alpha$. As an intermediate step we obtain a result quantifying the bias occurring in the second term of the asymptotic for the average running time of the \textit{by-excess} Euclidean algorithm, which is of independent interest.


Introduction and main results
In this work we are concerned with distributional questions regarding Dedekind sums and related questions in connexion with continued fraction expansions of rational numbers.
1.1.Dedekind sums.Dedekind sums have their genesis in the multiplier system for Dedekind's η function with respect to the modular group SL 2 (Z)/{±( 11 )}, first appearing in Dedekind's supplements to Riemann's collected works [6].A quick way of introducing them proceeds as follows.Let x denote the integer part of x ∈ R. If we denote by (( • )) the saw-tooth function, It can be verified that s(a, b) = s(ka, kb) for any non-zero integer k.Hence, s(a/b) := s(a, b) yields a well-defined function on Q ≥0 .
Here we are concerned with averages of Dedekind sums.Using the symmetry property s(1 − x) = −s(x), it is easy to see that (1.1) x s(x) = 0, when x ranges over the fractions in [0, 1] with fixed denominator.The same holds true, when the sum is extended over all fractions in [0, 1] with bounded denominator.On the other hand, when restricting to the fractions in [0, 1/2], then Ito [13] conjectured on the basis of numerical evidence that the above sum, divided by the number of terms, diverges to +∞.The main result of [16] is a proof of a quantitative version of this conjecture.To state it, let denote the set of Farey fractions of order Q.Moreover, for any α ∈ (0, 1), let The main result of [16] then states that Our main goal here is to prove the following generalisation of (1.2), allowing for arbitrary cuts α in place of 1/2.For rational α we have the following result: Theorem 1.1.Let α = v/w be a reduced rational number in (0, 1/2].Then (1).
The shape of the leading term in (1.2) raises the question as to how the corresponding results for irrational α might look.We do not resolve this here in full generality, as irrational α which are well approximable by rationals cause problems in our analysis.Nevertheless, we can prove the following partial result: Theorem 1.2.There is a subset S ⊆ [0, 1/2] of full Lebesgue measure such that for every α ∈ S one has the asymptotic formula

Asymptotics for the number of steps of Euclidean algorithms.
There is a well-known link between Dedekind sums, continued fraction expansions and Euclidean algorithms.To sketch this, we require some notation.Any rational number x ∈ [0, 1) admits a continued fraction expansion with partial quotients a 1 , a 2 , . . ., a n ∈ N. When requiring that a n = 1, which we shall do throughout the sequel, it is well known that n and the partial quotients are uniquely determined by x.The number n, for which we also write L(x), admits an interpretation as the number of steps of a certain variant of the Euclidean algorithm, whereas the sum a 1 + a 2 + . . .+ a n of partial quotients has a similar interpretation.We also let The link between Dedekind sums and continued fraction expansions is furnished by a formula due to Barkan [2] and Hickerson [12]: Consequently, the study of sums such as (1.1) is intimately linked with distribution properties of continued fractions or statistical properties of the number of steps of certain Euclidean algorithms.
The study of such properties has a long history and dates back to the seminal work of Lochs [15] and Heilbronn [10], who identified the principal term of the asymptotics for the average number of steps of the classical Euclidean algorithm here ϕ(n) is the Euler totient function, A 1 is an explicitly given non-zero constant and the error term is absolute.For the same average, an asymptotic formula with two significant terms was obtained later by Porter [18].These results are with respect to averages over numerators and fixed denominator.Concerning averages over both numerators and denominators, an asymptotic formula with power-law fall-off in the error term was obtained by Vallée [23].This was improved by Ustinov [22], who obtained an asymptotic formula with better fall-off in the error term than the one that can be derived from Porter's result 1 where B 1 and B 2 are explicitly given non-zero constants.While examining the statistical properties of different variants of the Euclidean algorithm, Vallée [24] obtained also the leading term of the asymptotic formula for the expectation of the number of steps of the so-called by-excess Euclidean algorithm which generates for a given rational number a/b ∈ (0, 1] the minus continued fraction expansion Zhabitskaya [25] improved upon Vallée's result by showing that if (a/b) = m denotes the number of partial quotients in the minus continued fraction expansion of a/b, then 1 here C 1 , C 2 , C 3 are explicitly given non-zero constants, the first two being given by (1.5) and γ denoting the Euler-Mascheroni constant.For more results regarding the expectation and the variance of the number of steps of the classical and by-excess Euclidean algorithm, we also refer to the work of Baladi and Vallée [1], Bykovskiȋ [4], Dixon [7,8], Hensley [11] and Ustinov [20,21].The approach to Ito's conjecture pursued in [16] rests crucially on the observation of Myerson [17,Lemma 5] that for some1 (x) ∈ {0, 1}, and on establishing the asymptotic formula where 2c 1 = C 1 and 2c 2 = C 2 + 3/4 with the constants C 1 and C 2 given by (1.5).Consequently, obtaining asymptotic formulas similar to the one above is a crucial step in proving Theorem 1.1 and Theorem 1.2.
To state our next theorem we introduce for a reduced rational number α = v/w in (0, 1] the quantity denotes the Hurwitz zeta-function. Theorem 1.3.Let Q be a positive integer and α = v/w be a reduced rational number in (0, 1] with w < Q 1/2 .Let also E(α) := (α) + (log w) 2 .Then 1.3.Structure of the paper.In § 2 we collect several technical lemmas.In § 3 we prove our results assuming Proposition 3.1, whose proof is given right after in § 4. Lastly, in § 5 we conclude with some remarks on Theorem 1.2.
1.4.Notation.We use the Landau notation f (x) = O(g(x)) and the Vinogradov notation f (x) g(x) to mean that there exists some constant C > 0 such that |f (x)| ≤ Cg(x) holds for all admissible values of x (where the meaning of 'admissible' will be clear from the context).Unless otherwise indicated, any dependence of C on other parameters is specified using subscripts.Similarly, we write 'f (x) = o(g(x)) as x → ∞' if g(x) is positive for all sufficiently large values of x and f (x)/g(x) tends to zero as x → ∞.
Given two coprime integers a and q = 0 we write inv q (a) for the least positive integer in the residue class (a mod q) −1 .
A sum with a star ( * ) is understood to involve the additional summation condition 'gcd(p, q) = 1'.Sums like n≤x are understood to range over all n = 1, 2, . . .not exceeding x.

Lemmas on modular inversion.
We require information on the distribution of modular inverses.The next lemma, itself a special case of a more general distribution result (see [19,Theorem 13]), which follows from Weil's bound on exponential sums, contains what we need.
Lemma 2.1.Let p be a positive integer, α ∈ (0, 1], X 2 > X 1 ≥ 0.Then, for any > 0, both sums * Proof.The proof is identical to that of [16,Lemma A.1] where the special case α = 1/2 is considered.We omit the details. The next result allows one to pass from inv p (q) to inv q (p).A special case of this was already used in [16,Lemma 4.1].
Proof.We start with the well-known identity ).From this, by rearranging terms, we infer that inv p (q) ≤ αp if and only if inv q (p) ≥ (1 − α)q + 1 p .
The result now easily follows by appealing to either of the two assumptions w ≤ p or w ≤ q.
Proof.We begin by rewriting the summation condition gcd(p, q) = 1 implicit in * using Möbius inversion.Hence, The sets on the right hand side have cardinality αq/d + {(1 − α)q/d}.Hence, The first sum on the right hand side equals ϕ(q).Upon grouping the terms of the second sum by the residue d mod w, we obtain the function κ α (q).

Continued fractions.
The key step in the approach of Lochs [15] and Heilbronn [10] to statistics of lengths of (ordinary) continued fraction expansions is the transference of the problem to a problem of counting solutions to certain Diophantine inequalities.Here we require a version for minus continued fraction expansions.Such a version was initially given by Zhabitskaya [25, Lemma 2].In [16,Lemma 4.3] the authors employed a restricted variant of this, which we generalize below in the case of arbitrary rational cuts.
Lemma 2.4.Let α be a rational number in (0, 1] and Q be a positive integer.If N α (Q) denotes the sum of the lengths of the minus continued fraction expansions of the numbers a/b with 1 ≤ a < αb, q ≤ Q, and T α (Q) denotes the number of solutions (a 1 , q 1 , a 2 , q 2 , m, n, a, b) ∈ N 8 of the following system of equalities and inequalitites (2.1) Proof.Following [25, Lemma 2] we know that N α (Q) is, apart from an error O(Q 2 ), equal to the number of solutions of (2.2) In particular, the pairs (p 1 , q 1 ) and (p 2 , q 2 ) generated from each solution of the above system are successive convergents of the minus continued fraction expansion of a/b other than a/b itself [25, Lemma 1].Moreover, the sequence of these convergents is monotonically decreasing to a/b.Therefore, if It is not generally true that if a/b is less than α then so is the case for its convergents.However, if (a/b) ≥ (α), then the (α)-th convergent of a/b will be less than or equal to α, and so will be the succeeding convergents since they form a strictly decreasing sequence.Indeed, if α = 1; t 1 , . . ., t u and a/b = 1; s 1 . . ., s v < α with u ≤ v, then 1; s 1 , . . ., s u ≤ α.For if 1; s 1 ≤ α then we are done.Otherwise, the inequalities a/b < α < 1; s 1 imply that s 1 = t 1 .If now 1; t 1 , s 2 ≤ α then we are done.Otherwise, the inequalities a/b < α < 1; t 1 , s 2 imply that s 2 = t 2 .Repeating these steps at most (α) times, we obtain the desired inequality.
Hence, for each pair (a, b), the number of solutions of the systems (2.1) and (2.2) differ by at most (α).Since we count O(Q 2 ) pairs (a, b), the lemma follows.
The eight variables in Lemma 2.4 can be reduced to four.This is the contents of the next lemma.Lemma 2.5.Let α be a rational number in (0, 1] and Q be a positive integer.If R α (Q) denotes the number of solutions (p, q, n, m) ∈ N 4 of the following system of inequalities Proof.As in [16,Lemma 4.4], one shows that 2.3.Auxiliary asymptotic formulae.We conclude this section with a list of formulae which will be employed in the succeeding proofs.
Lemma 2.7.The following asymptotic formulae hold for any x ≥ 2: (1) If in addition α := v/w is a reduced rational in the unit interval and κ α is defined as in Lemma 2.3, then for x > w Proof.The first two formulae are well known and the proof of the third one can be found in [3,Corollary 4.5].Formula (4) can be deduced easily from (3) and partial summation.The last formula follows directly from the definitions of κ α (q) and ζ(s, x), and computations of well-known harmonic sums via the Euler-Maclaurin summation formula.
Lemma 2.8.The following asymptotic formulae hold for any U ≥ 2: (1) Proof.They follow directly from the formulae of the previous lemma.

Proofs of the main results
In this section we state our main technical result (Proposition 3.1 below) and show how to deduce Theorem 1.3 from it.We then proceed on proving Theorem 1.1 and Theorem 1.2.The proof of Proposition 3.1 is given in § 4.
The main step is counting the number of solutions to the systems (2.3) asymptotically.For technical reasons, it turns out to be convenient to group these solutions according to the size of their components and count the number of solutions in each group individually.To fix the relevant notation, let U = Q 1/2 , and consider the following five cases: ('Case 5') Proposition 3.1.Let α = v/w be a reduced rational number in (0, 1] and Q ≥ 1 be real.For i = 1, 2, 3, 4, 5, let R i,α (U ) denote the number of solutions (p, q, n, m) to the systems (2.3) subject to the additional constraint that 'Case i' be satisfied.Then we have the following asymptotic formulae: Assuming the conclusion of Proposition 3.1 for the moment, we are now in position to prove our main results.
Proof of Theorem 1.3.Let Q ≥ 1 be an integer and put U = Q 1/2 .From Lemma 2.5 and Proposition 3.1 we know that Moreover, by Möbius inversion, The first formula of the theorem follows now from the above, Lemma 2.6 and the well-known formula The second formula of the theorem follows from the first one by observing that Proof of Theorem 1.1.If x has continued fraction expansion x = [0; a 1 , . . ., a n ], then, by (1.4), s(x) = Σ ± (x)/12 + O(1), where the implied constant is absolute.In view of (1.6) we obtain that 12 The theorem follows now from Theorem 1.3.

Proof of Theorem 1.2. Let
where φ is the golden ratio.One can easily show by standard techniques from the metric theory of continued fractions (see for example [14]), that the set S is of full Lebesgue measure.Let α ∈ S and f (Q) be a monotonically increasing positive function such that We employ this property and the one describing the set S to prove Theorem 1.2.Indeed, let Q be any sufficiently large positive integer.There is a positive integer N = N (Q), which we assume w.l.o.g. that is even, such that Observe that in view of (1.6) Therefore, the error terms appearing in Theorem 1.3 for the case of β := p N /q N and β := p N +1 /q N +1 are all bounded from above by Since β and β are successive convergents of α, we know that β −β = 1/(q N q N +1 ).In addition to relation (3.1) and Theorem 1.3 we obtain that where the last sum is also O(1/q N ) as can be seen from {βr}−{β r} = −r/(q N q N +1 ).

Proof of Proposition 3.1
This section is devoted to the proof of Proposition 3.1, where we follow the same procedure as in [16].Therefore, we heavily refer to [16] to shorten certain parts of the proof.
Case 1.We count the number of solutions R 1,α (U ) of Following [16, § 5, Case 1] with αp in place of p/2, we find that Case 2. We count the number of solutions R 2,α (U ) of Observe that in this case the inequalities n ≤ U 2 /q < U hold as well.
Consider the pairs (n, k) ∈ N 2 for which 1 ≤ k < n and n + k > U .In that case the number of solutions of the above system is smaller than the number of solutions of the same system without the restrictions on coprimality and modular inversion.This number has been estimated in [25, (54)-(56)] to be O(U 4 ).
Let C := { (p, q) ∈ Z 2 : gcd(p, q) = 1 }.It suffices to consider the number of solutions of the system (4.1) with the additional restriction n + k ≤ U .If we fix such a pair (n, k), then the domain of solutions of (4.1) can be expressed as the lattice The number of integer points of L 1 (n, k) and L 2 (n, k) is equal to and respectively, where A (p,α) (x, y) is defined as in Lemma 2.1.By following [16, § 5, Case 2] with A (p,α) in place of A (p,1/2) , we obtain that Case 3. We count the number of solutions R 3,α (U ) of Similar to Case 1 (see also [25, (58)-(60)]), the number of solutions of the above systems are, up to an error term of order O(U 3 log U ), equal to We rewrite the first double sum above as By partial summation and Lemma 2.1 we obtain for fixed ∈ (0, 1/2) that To estimate S 1 (U ) we will first apply Lemma 2.2, obtaining where v q := max{w, q} and V q := min{U, q 2 }.Then partial summation and Lemma 2.1 yield that * Therefore, for fixed ∈ (0, 1/4), we deduce that For S(α) we have the trivial bound O((log w) 2 ).It remains to estimate S 2 (U ) to which we will apply first Lemma 2.2.Observe here that to do so we will have to remove from S 2 (U ) the sum corresponding to q = 1.This sum is always included in S 2 (U ) since p > w.Therefore, where u q := max{w, q 2 }.Since for any coprime integers 1 ≤ b ≤ q, we obtain from partial summation that uq<p≤U p≡invq(b) Hence, where δ α (q) ≤ q was defined in Lemma 2.3.In view of the aforementioned lemma, we conclude that Observe that κ α (q) ≤ d(q), where d(n) denotes the number of divisors of n.Therefore, the last sum in the last line above is O(1) and, thus, It follows now from Lemma 2.7 and relations (4.2) and ( 4.3) that Case 4. We count the number of solutions R 4,α (U ) of Similar to Case 2, we fix k and n, and count the number of solutions of the above system, when n + k ≤ U , and when n + k > U .
If n + k > U , then the number of solutions of (4.4) is smaller than the number of solutions of the same system without the restrictions on coprimality and modular inversion.This number has been computed in [25, (64)-(65)] to be O(U 4 ).
If now n + k ≤ U , then the domain of solutions of (4.4) can be expressed as the union of lattices without the lattice of integer points where we have also applied Lemma 2.2 in L 2,α (n, k) and have introduced a parameter θ ∈ [0, 1] which may vary.The number of points of and respectively.Working as in [16, § 5, Case 4], and using Lemma 2.1, we obtain that Therefore, by fixing ∈ (0, 1/4), we conclude that Case 5. We count the number of solutions R 5,α (U ) of which, apart from the number of solutions corresponding to q = 1, is equivalent to as can be seen from Lemma 2.2.We may restrict ourselves to the case k + q < U for, otherwise, the system (4.5) has no solution.If S(k, q) denotes the number of solutions of (4.5) for fixed k and q, then where x is the ceiling function.

Remarks and some heuristics
In this final section we discuss briefly the result we obtained.In particular, we want to formalize the intuition that the main contribution to the sample at irrational cuts is carried by the points which are 'arbitrarily' close to 0. To this end, we borrow an elementary argument from [5]. .
Then we have that a b ∈S(g,Q) s(b, a) Q 2 g(Q) 2 log 2 (Q).where the maximum ranges over all subsets S of the set of the residue classes modulo a.Moreover, it is known (see for example the introduction of [9]) that * k<a |s(k, a)| a log 2 a.
Using the above facts we conclude that a<Q/g(Q) ag(Q)<b<Q s(b, a) a<Q/g(Q) a log 2 a Q 2 g(Q) 2 log 2 (Q).
The lemma follows by Möbius inversion and computing the resulting double sum.

Lemma 5 . 1 .
Let g : R → R be a monotonically increasing function with lim x→∞ g(x) = ∞ and define the set S(g, Q) = a b ∈ Q : b ≤ Q and a

Proof.
We start by writing a b ∈S(g,Q) s(b, a) = a<Q/g(Q) ag(Q)<b<Q s(b, a) Since s(b, a) = s b, a , where b denotes the reduction of b modulo a, relation (1

Lemma 5 . 2 .
Let g(x) = log x and S(g, Q) be as in Lemma 5.1.Then1 F(Q) a b ∈S(g,Q) s(a, b) = 1 12 log Q + O (log log Q) .Proof.By the reciprocity law for Dedekind sums s(a, b) + s(b, a) Each of the above sums is computed in Lemma 2.7 and Lemma 2.8.Thus, we conclude that 4.