1 Introduction

Given an integer \(N \geqslant 1,\) and \(j =1, \ldots , N,\) we denote by \(q_j(N)\) the smallest integer q such that, for some a,  we have

$$\begin{aligned} \frac{a}{q} \in \left( \frac{j-1}{N}, \frac{j}{N}\right] . \end{aligned}$$

Next, we consider the average value

$$\begin{aligned} S(N) = \frac{1}{N} \sum _{j=1}^N q_j(N). \end{aligned}$$

Recently, Balazard and Martin [2] have confirmed the conjecture of Kruyswijk and Meijer [10] that

$$\begin{aligned} S(N) \sim \frac{16}{\pi ^2} N^{3/2} \end{aligned}$$

and in fact established the following much more precise asymptotic formula

$$\begin{aligned} S(N) = \frac{16}{\pi ^2} N^{3/2} + O\left( N^{4/3} (\log N)^2\right) , \end{aligned}$$
(1.1)

see [2, Equation (1)]. Note that the asymptotic formula (1.1) improves on previous upper and lower bounds of Kruyswijk and Meijer [10] and Stewart [13], for example on the previous inequalities

$$\begin{aligned} 1.35N^{3/2}< S(N) < 2.04 N^{3/2} \end{aligned}$$

in [13] (note that \(16/\pi ^2 = 1.6211 \ldots \)). For other related results, see [1, 4, 5, 7, 11, 12] and references therein.

The bound on the error term in (1.1) is based on the classical bound of Kloosterman sums, see, for example, [9, Corollary 11.12].

Here, we use bounds on bilinear forms with Kloosterman fractions due to Duke et al. [6], and improve the error term in the asymptotic formula (1.1) as follows.

Theorem 1.1

We have

$$\begin{aligned} S(N) = \frac{16}{\pi ^2} N^{3/2} + O\left( N^{29/22 + o(1)} \right) , \end{aligned}$$

as \(N\rightarrow \infty .\)

2 Preliminary reductions

As usual, we use the expressions \(U \ll V\) and \(U=O(V)\) to mean \(|U|\le c V\) for some constant \(c>0\) which throughout this paper is absolute.

We have

$$\begin{aligned} S(N) = \frac{16}{\pi ^2} N^{3/2} + R(N), \end{aligned}$$
(2.1)

where by [2, Equations (19), (20), and (21)], we can write

$$\begin{aligned} R(N) \ll T_{11}(N) + T_{12}(N) + T_{2}(N) \end{aligned}$$
(2.2)

for some quantities \(T_{11}(N),\) \(T_{12}(N),\) and \(T_{2}(N)\) which are estimated in [2] separately. In particular, by [2, Equations (23) and (26)], we have

$$\begin{aligned} T_{12}(N) \ll N^{5/4} (\log N)^2 \quad \text{ and } \quad T_{2}(N) \ll N^{5/4} (\log N)^2. \end{aligned}$$
(2.3)

Therefore, the error term in (1.1) comes from the bound

$$\begin{aligned} T_{11}(N) \ll N^{4/3} (\log N)^2 \end{aligned}$$
(2.4)

given by [2, Equation (22)].

We now see from (2.1), (2.2), and (2.3) that in order to establish Theorem 1.1 we only need to improve (2.4) as

$$\begin{aligned} T_{11}(N) \ll N^{29/22 + o(1)} . \end{aligned}$$
(2.5)

We first recall the following expression for \(T_{11}(N)\) given in [2, Section 5.3]:

$$\begin{aligned} T_{11}(N) = \sum _{s \geqslant \sqrt{N} } \sum _{\begin{array}{c} 1 \leqslant r \leqslant R_s\\ \gcd (r,s)=1 \end{array}} r B_1\left( \frac{N r^{-1}}{s}\right) \end{aligned}$$
(2.6)

with the Bernoulli function

$$\begin{aligned} B_1(u) = {\left\{ \begin{array}{ll} 0 &{} \text {if}\ u \in {{\mathbb {Z}}}, \\ \{u\}-1/2 &{} \text {if}\ u \in {{\mathbb {Z}}}, \end{array}\right. } \end{aligned}$$

where \(\{u\}\) is the fractional part of a real u,  the inversion \( r^{-1}\) in the fractional part \(\{N r^{-1}/s\}\) is computed modulo s,  and \(R_s\) is a certain sequence of positive integers, satisfying

$$\begin{aligned} R_s \ll N/s \end{aligned}$$
(2.7)

(we refer to [2] for an exact definition, which is not important for our argument).

It is more convenient for us to work with the function

$$\begin{aligned} \psi (u) = \{u\}-1/2, \end{aligned}$$

which coincides with \(B_1(u) \) for all \(u \not \in {{\mathbb {Z}}}.\)

In particular,

$$\begin{aligned} B_1\left( \frac{N r^{-1}}{s}\right) = \psi \left( \frac{N r^{-1}}{s}\right) \end{aligned}$$

unless \(s \mid N.\)

Using the classical bound on the divisor function

$$\begin{aligned} \tau (k) = k^{o(1)}, \end{aligned}$$
(2.8)

for a positive integer \(k \rightarrow \infty \) (see, for example, [9, Equation (1.81)]), we infer from (2.6) that

$$\begin{aligned} T_{11}(N) =U(N) + E(N) , \end{aligned}$$
(2.9)

where

$$\begin{aligned} U(N) = \sum _{s \geqslant \sqrt{N} } \sum _{\begin{array}{c} 1 \leqslant r \leqslant R_s\\ \gcd (r,s)=1 \end{array}} r \psi \left( \frac{N r^{-1}}{s}\right) , \end{aligned}$$
(2.10)

and, using (2.7),

$$\begin{aligned} E(N) \ll \sum _{\begin{array}{c} s \geqslant \sqrt{N} \\ s \mid N \end{array}} R_s^2 \ll N^2 \sum _{\begin{array}{c} s \geqslant \sqrt{N} \\ s \mid N \end{array}} s^{-2} \leqslant N^{1+o(1)}. \end{aligned}$$
(2.11)

3 Vaaler polynomials

For a real z, let \(\mathbf {\,e}(z) = \exp (2 \pi z)\). By a result of Vaaler [14], see also [8, Theorem A.6], we have the following approximation of \(\psi (u).\)

Lemma 3.1

For any integer \(H\geqslant 1,\) there is a trigonometric polynomial

$$\begin{aligned} \psi _H(u) = \sum _{1\le \left| h \right| \le H} \frac{a_h}{-2i\pi h} \mathbf {\,e}(hu) \end{aligned}$$

for coefficients \(a_h\in [0,1]\) and such that

$$\begin{aligned} \left| \psi (u)-\psi _H(u) \right| \leqslant \frac{1}{2H+2} \sum _{\left| h \right| \le H} \left( 1-\frac{\left| h \right| }{H+1}\right) \mathbf {\,e}(hu). \end{aligned}$$
(3.1)

4 Bilinear forms with Kloosterman fractions

Here we collect some estimates on bilinear forms with exponentials \( \mathbf {\,e}\left( hr^{-1}/s\right) \) where, as before, \( r^{-1}\) in the argument is computed modulo s.

For \(U\geqslant 1,\) we also use \(u \sim U\) to indicate \(U \leqslant u < 2U.\)

We start with recalling the following bound of Duke et al. [6, Theorem 1].

Lemma 4.1

For sequences \({\varvec{\alpha }}= \{\alpha _r\}_{r=1}^\infty ,\) \({\varvec{\beta }}= \{\beta _s\}_{s=1}^\infty \) of complex numbers,  a nonzero integer K,  and real positive R and S,  we have

$$\begin{aligned}&\left| \sum _{s \sim S} \sum _{\begin{array}{c} r \sim R\\ \gcd (r,s) = 1 \end{array}} \alpha _r \beta _s \mathbf {\,e}\left( Kr^{-1}/s\right) \right| \\&\quad \leqslant \Vert {\varvec{\alpha }}\Vert \Vert {\varvec{\beta }}\Vert \left( (R + S)^{1/2} +\left( 1 + \frac{K}{RS}\right) ^{1/2} \min \{R,S\}\right) (RS)^{o(1)}, \end{aligned}$$

where

$$\begin{aligned} \Vert {\varvec{\alpha }}\Vert =\left( \sum _{r \sim R}|\alpha _r|^2\right) ^{1/2} \quad \text{ and } \quad \Vert {\varvec{\beta }}\Vert =\left( \sum _{s \sim S}|\beta _s|^2\right) ^{1/2}. \end{aligned}$$

Next, given two sequences of complex numbers

$$\begin{aligned} {\varvec{\alpha }}= \{\alpha _r\}_{r=1}^\infty \quad \text{ and } \quad {\varvec{\beta }}= \{\beta _s\}_{s=1}^\infty , \end{aligned}$$

a sequence of positive integers

$$\begin{aligned} {{\mathcal {R}}}= \{\beta _s\}_{s=1}^\infty , \end{aligned}$$

and an integer h,  for \(S \geqslant 1,\) we define the bilinear form

$$\begin{aligned} {\mathscr {B}}_K(S; {{\mathcal {R}}}, {\varvec{\alpha }}, {\varvec{\beta }}) = \sum _{s \sim S} \sum _{\begin{array}{c} r =1\\ \gcd (r,s) = 1 \end{array}}^{R_s} \alpha _r \beta _s \mathbf {\,e}\left( Kr^{-1}/s\right) . \end{aligned}$$

Note that in the sums \({\mathscr {B}}_K(S; {{\mathcal {R}}}, {\varvec{\alpha }}, {\varvec{\beta }})\) the range of summation over r depends on s and hence Lemma 4.1 does not directly apply.

We observe that for

$$\begin{aligned} \alpha _r = r, \quad \beta _s \ll 1, \quad R_s \ll \min \{N/s, s\}, \qquad r,s =1, 2, \ldots , \end{aligned}$$
(4.1)

the argument in [2, Section 3] (in which we also inject the bound (2.8)) immediately implies that for

$$\begin{aligned} 0< |K| = N^{O(1)} \quad \text{ and } \quad 0 < S \ll N, \end{aligned}$$

we have

$$\begin{aligned} {\mathscr {B}}_K(S; {{\mathcal {R}}}, {\varvec{\alpha }}, {\varvec{\beta }})\ll & {} \sum _{s \sim S} \gcd (K, s)^{1/2} R_s s^{1/2} \log s\nonumber \\\leqslant & {} N^{1+o(1)}\sum _{s \sim S} \gcd (K, s)^{1/2} s^{-1/2} \nonumber \\\leqslant & {} N^{1+o(1)} S^{-1/2} \sum _{d\mid K} d^{1/2} \sum _{\begin{array}{c} s \leqslant 2S\\ d \mid s \end{array}} 1 \nonumber \\\leqslant & {} N^{1+o(1)} S^{-1/2} \sum _{d\mid K} d^{1/2} \left\lfloor 2S/d\right\rfloor \nonumber \\\leqslant & {} N^{1+o(1)} S^{1/2} \sum _{d\mid K} d^{-1/2} \nonumber \\\leqslant & {} N^{1+o(1)} S^{1/2}. \end{aligned}$$
(4.2)

Note that one can also derive (4.2) via [6, Lemma 8] and partial summation.

In fact, using the bound (4.2) for \(S \leqslant N^{2/3}\) and the trivial bound

$$\begin{aligned} {\mathscr {B}}_K(S; {{\mathcal {R}}}, {\varvec{\alpha }}, {\varvec{\beta }}) \ll \sum _{s \sim S} R_s^2 \ll N^2S^{-1} \end{aligned}$$

in our argument below, one recovers the asymptotic formula (1.1). However, using some other bounds, we achieve a stronger result.

We also remark that for us only the choice of \({\varvec{\alpha }}= \{\alpha _r\}_{r=1}^\infty \) satisfying (4.1) matters. However we present the below results for a more general \({\varvec{\alpha }}\) (but still they admit even more general forms).

Using Lemma 4.1 together with the standard completing technique, see, for example, [9, Section 12.2], we derive our main technical tool.

Lemma 4.2

For sequences \({\varvec{\alpha }}= \{\alpha _r\}_{r=1}^\infty ,\) \({\varvec{\beta }}= \{\beta _s\}_{s=1}^\infty \), and \({{\mathcal {R}}}= \{R_s\}_{s=1}^\infty ,\) a nonzero integer K and real S with

$$\begin{aligned} \alpha _r \ll A, \quad \beta _s \ll B, \quad R_s \ll \min \{N/s, s\}, \qquad r,s =1, 2, \ldots , \end{aligned}$$

and

$$\begin{aligned} N^{1/2} \ll S \ll N, \end{aligned}$$

we have

$$\begin{aligned} \left| {\mathscr {B}}_K(S; {{\mathcal {R}}}, {\varvec{\alpha }}, {\varvec{\beta }}) \right| \leqslant AB (RS)^{1/2} \left( S^{1/2} + R+ K^{1/2} S^{-1/2} R^{1/2}\right) N^{o(1)}, \end{aligned}$$

where

$$\begin{aligned} R = \max \{R_s: ~ s\sim S\}. \end{aligned}$$

Proof

Note that

$$\begin{aligned} R \ll N/S \ll S. \end{aligned}$$
(4.3)

Using the orthogonality of exponential functions, we write

$$\begin{aligned}&{\mathscr {B}}_K(S; {{\mathcal {R}}}, {\varvec{\alpha }}, {\varvec{\beta }}) \\&\quad = \sum _{s \sim S} \sum _{\begin{array}{c} r =1\\ \gcd (r,s) = 1 \end{array}}^{R_s} \alpha _r \beta _s \mathbf {\,e}\left( Kr^{-1}/s\right) \\&\quad = \sum _{s \sim S} \sum _{\begin{array}{c} r =1\\ \gcd (r,s) = 1 \end{array}}^{R} \alpha _r \beta _s \mathbf {\,e}\left( Kr^{-1}/s\right) \frac{1}{R} \sum _{u=0}^{R-1}\sum _{t=1}^{R_s} \mathbf {\,e}(u(t - r)/R) \\&\quad = \frac{1}{R} \sum _{u=0}^{R-1} \sum _{s \sim S} \sum _{\begin{array}{c} r =1\\ \gcd (r,s) = 1 \end{array}}^{R} \alpha _r \mathbf {\,e}(-ur/R) \beta _s \mathbf {\,e}\left( Kr^{-1}/s\right) \sum _{t=1}^{R_s}\mathbf {\,e}(ut/R) . \end{aligned}$$

Using that

$$\begin{aligned} \sum _{t=1}^{R_s} \mathbf {\,e}(ut/R) \ll \frac{R}{\min \{u, R- u\} + 1}, \end{aligned}$$

see [9, Equation (8.6)], we derive

$$\begin{aligned} {\mathscr {B}}_K(S; {{\mathcal {R}}}, {\varvec{\alpha }}, {\varvec{\beta }})&\ll \frac{1}{R} \sum _{u=0}^{R-1} \frac{R}{\min \{u, R- u\} + 1}\\&\quad \times \left| \sum _{s \sim S} \sum _{\begin{array}{c} r =1\\ \gcd (r,s) = 1 \end{array}}^{R} \alpha _r \mathbf {\,e}(-ur/R) \beta _s \mathbf {\,e}\left( Kr^{-1}/s\right) \right| . \end{aligned}$$

It remains to observe that, for each \(u = 0, \ldots , R-1,\) the bound of Lemma 4.1 applies to the inner sum and implies

$$\begin{aligned}&\left| {\mathscr {B}}_K(S; {{\mathcal {R}}}, {\varvec{\alpha }}, {\varvec{\beta }}) \right| \\&\quad \leqslant AB (RS)^{1/2} \left( (R + S)^{1/2} + \left( 1 + \frac{K}{RS}\right) ^{1/2} \min \{R,S\}\right) N^{o(1)}. \end{aligned}$$

Recalling (4.3), this now simplifies as

$$\begin{aligned} \left| {\mathscr {B}}_K(S; {{\mathcal {R}}}, {\varvec{\alpha }}, {\varvec{\beta }}) \right|&\leqslant AB (RS)^{1/2} \left( S^{1/2} + \left( 1 + \frac{K}{RS}\right) ^{1/2}R\right) N^{o(1)}\\&= AB (RS)^{1/2} \left( S^{1/2} + R+ K^{1/2} S^{-1/2} R^{1/2}\right) N^{o(1)}, \end{aligned}$$

which concludes the proof. \(\square \)

Remark 4.3

Instead of using Lemma 4.1, that is, essentially [6, Theorem 1], one can also derive a version of Lemma 4.2 from [6, Theorem 2], or from a stronger result due to Bettin and Chandee [3, Theorem 1]. However these bounds do not seem to improve our main result.

5 Proof of Theorem 1.1

As we have noticed in Section 2, it is enough to only estimate \(T_{11}(N),\) as we borrow the bounds on \(T_{12}(N)\) and \(T_{2}(N)\) from [2]. Furthermore, we see from (2.9) and (2.11) that it is enough to estimate U(N) given by (2.10).

We note that it is important to observe that the sum defining \(\psi _H(u)\) in Lemma 3.1 does not contain the term with \(h=0,\) while the sum on the right hand side of (3.1) does. Hence, for any integer \(H\geqslant 1,\) by Lemma 3.1, we have

Note that \(R_s\geqslant 1\) implies \(s \ll N.\) Therefore, partitioning the corresponding summation over s into dyadic intervals, we see that there is some integer S with

$$\begin{aligned} N^{1/2} \ll S \ll N \end{aligned}$$

and such that

$$\begin{aligned} U(N) \ll H^{-1} N^{3/2} + V(N,S) \log N, \end{aligned}$$
(5.1)

where

$$\begin{aligned} V(N,S) = \sum _{1\le \left| h \right| \le H} \frac{1}{ h}\left| \sum _{s \sim S} \sum _{\begin{array}{c} r =1\\ \gcd (r,s) = 1 \end{array}}^{R_s} r \mathbf {\,e}\left( hNr^{-1}/s\right) \right| . \end{aligned}$$

Now, if \(S \leqslant H^{1/5} N^{3/5},\) then we use the bound (4.2) and easily derive

$$\begin{aligned} V(N,S) \leqslant N^{1+o(1)} S^{1/2} \leqslant H^{1/10} N^{13/10+ o(1)}. \end{aligned}$$
(5.2)

On the other hand, for \(S > H^{1/5} N^{3/5},\) Lemma 4.2 (used with \(A\ll N/S\) and \(B \ll 1\)), after recalling that \(R \ll N/S,\) implies the same bound:

$$\begin{aligned}&\sum _{s \sim S} \sum _{\begin{array}{c} r =1\\ \gcd (r,s) = 1 \end{array}}^{R_s} r \mathbf {\,e}\left( hNr^{-1}/s\right) \\&\quad \leqslant (N/S) N^{1/2+o(1)} \left( S^{1/2} + NS^{-1} + h^{1/2} N S^{-1} \right) \\&\quad \leqslant (N/S) N^{1/2+o(1)} \left( S^{1/2} + h^{1/2} N S^{-1} \right) . \end{aligned}$$

Therefore, recalling that \(S > H^{1/5} N^{3/5},\) we obtain

$$\begin{aligned} V(N,S)&\leqslant (N/S) N^{1/2+o(1)} \left( S^{1/2} + H^{1/2} N S^{-1} \right) \\&= N^{3/2+o(1)} S^{-1/2} + H^{1/2} N^{5/2+o(1)} S^{-2}\\&\leqslant H^{-1/10} N^{6/5+o(1)} + H^{1/10} N^{13/10+o(1)} \\&\leqslant H^{1/10} N^{13/10+o(1)} . \end{aligned}$$

Therefore, the bound (5.2) holds for any S. Substituting (5.2) in (5.1) yields

$$\begin{aligned} U(N) \ll H^{-1} N^{3/2} + H^{1/10} N^{13/10+o(1)} \end{aligned}$$

and choosing

to optimise the bound, we obtain

$$\begin{aligned} U(N) \ll N^{29/22+o(1)}. \end{aligned}$$

Finally, recalling (2.9) and (2.11), we derive (2.5) and conclude the proof.