1 Introduction

Let q be an odd integer, c be a fixed positive integer with \((c,q)=1\). For each integer a with \(1\leqslant a\leqslant q-1\) and \((a,q)=1\), it is clear that there exists one and only one integer b with \(1\leqslant b\leqslant q-1\) such that \(ab\equiv c (\bmod q)\). If a and b are of opposite parity, then a is called a Lehmer number. Let \(\mathcal{A}(c,q)\) denote the set of all Lehmer numbers, and \(r(c,q)\) the number of \(\mathcal{A}(c,q)\). Lehmer [1] posed the problem of finding \(r(1,q)\).

Before proceeding we need to recall that the notations \(U = O(V)\) and \(U \ll V\) are equivalent to \(\vert U\vert \le c V\) for some constant \(c>0\). We write \(\ll_{\rho}\) and \(O_{\rho}\) to indicate that this constant may depend on the parameter ρ. \(\sum^{'}\) means summing over reduced residue classes, denotes the multiplicative inverse of a modulo q and for a real x we denote \(e(x)=e^{2\pi i x}\), \(\{x\}\) the fractal part of x, and \(\langle x\rangle=\min\{\{x\},1-\{x\}\}\).

In 1993, Zhang [2] proved that

$$\begin{aligned}& r \bigl(1,p^{\alpha} \bigr)=\frac{\phi(p^{\alpha})}{2}+O \bigl(p^{\alpha/2}\ln ^{3} \bigl(p^{\alpha} \bigr) \bigr), \\ & r(1,pl)=\frac{\phi(pl)}{2}+O \bigl((pl)^{1/2}\ln^{2}(pl) \bigr), \end{aligned}$$

where p, l are two distinct odd primes, α is a positive integer, and \(\phi(q)\) is the Euler function. For arbitrary odd integer \(q\ge3\), he [3] soon obtained

$$r(1,q)=\frac{\phi(q)}{2}+O \bigl(q^{1/2}d^{2}(q) \ln^{2}q \bigr), $$

where \(d(q)\) is the classical divisor function.

Later, Lu and Yi [4] generalized this problem to incomplete intervals. In fact, let \(q\ge3\) be an integer, \(n\geqslant2\) and c be two fixed integers with \((n,q)=(c,q)=1\), \(0<\delta_{1},\delta _{2}\leqslant1\), they defined

$$r_{n}(\delta_{1},\delta_{2},c;q)=\mathop{ \mathop{\mathop{{\sum }'}_{a\leqslant\delta_{1}q}\ \mathop{{\sum }'}_{b\leqslant\delta_{2}q}}_{ab\equiv c (\bmod q)}}_{n\nmid(a+b)}1, $$

and got an asymptotic formula as follows:

$$r_{n}(\delta_{1},\delta_{2},c;q)= \biggl(1- \frac{1}{n} \biggr)\delta _{1}\delta_{2}\phi(q) +O_{n} \bigl(q^{1/2}d^{6}(q)\log^{2}q \bigr). $$

Recently, interesting connections between Lehmer numbers and character sums were investigated by some scholars. For example, for an odd prime p, and a fixed prime w less than p, let

$$\mathcal{B}(w,p)= \bigl\{ a\mid 1\leqslant a\leqslant p-1, a\overline{a}\equiv1 ( \bmod p), a\equiv\overline{a} (\bmod w) \bigr\} . $$

Then, for any non-principal Dirichlet character \(\chi \bmod w\), Ma, Zhang and Zhang [5] got an upper bound estimate of character sums over \(\mathcal{B}(w,p)\) as

$$\mathop{\mathop{\sum}_{a=1}}_{a\in\mathcal{B}(w,p)}^{p-1}\chi (a)\ll_{w} p^{1/2+\epsilon}. $$

At almost the same time, Han and Zhang [6] obtained an upper bound estimate of the character sums over Lehmer numbers as

$$\begin{aligned} \sum_{a\in\mathcal{A}(1,p)}\chi (a)= \mathop{\mathop{ \sum }_{a=1}}_{2 \nmid(a+\overline {a})}^{p-1}\chi(a)\ll p^{1/2} \ln^{2}p, \end{aligned}$$
(1.1)

where χ is an arbitrary non-principal character modulo an odd prime p.

The results of character sums over other special numbers or polynomials can also be found in [7] and [8]. For more properties of character sums and their various applications, see [9, 10] and the references therein.

It seems that (1.1) cannot be extended to arbitrary integer q by their methods in [6]. However, relying on the methods in [4], we can overcome the obstacles.

Let \(q\ge3\) be an integer, \(n\geqslant2\) be a fixed integer with \((n,q)=1\), ψ be a non-principal Dirichlet character modulo q. If \(n\nmid (a+\overline{a})\), then a is called a generalized Lehmer number. Denote the set of all generalized Lehmer numbers by

$$\mathcal{C}(1,q)= \bigl\{ a \mid 1\leqslant a\leqslant q-1, a\overline{a}\equiv 1 (\bmod q), n\nmid(a+\overline{a}) \bigr\} . $$

Following the same technique as in [4], we obtain the following.

Theorem

Let \(q\ge3\) be an integer, \(n\geqslant2\) be a fixed integer with \((n,q)=1\), ψ be a non-principal Dirichlet character \(\bmod\ q\). Then we have the upper bound estimate

$$\sum_{a\in\mathcal{C}(1,q)}\psi(a)=\mathop{\mathop {{\sum }'}_{a=1}}_{n\nmid(a+\overline{a})}^{q}\psi(a) \ll_{n} q^{1/2}d^{5}(q)\log^{2}q. $$

Let \(q\ge3\) be an odd integer, \(n=2\) in the theorem, we may immediately obtain the following.

Corollary 1

Let ψ be a non-principal Dirichlet character modulo q. Then we have

$$\sum_{a\in\mathcal{A}(1, q)}\psi(a)=\mathop{\mathop {{\sum }'}_{a=1}}_{2\nmid(a+\overline{a})}^{q}\psi(a)\ll q^{1/2}d^{5}(q)\log^{2}q. $$

Let q be an odd prime p, \(n=2\) in Corollary 1, then (1.1) can be deduced directly as follows.

Corollary 2

Let ψ be a non-principal Dirichlet character modulo p. Then we have

$$\sum_{a\in\mathcal{A}(1, p)}\psi(a)\ll p^{1/2} \log^{2}p. $$

2 Some lemmas

To prove the theorem, we need the following several lemmas. First we need an upper bound estimate of the general Kloosterman sum \(S(m,n,\chi;q)\) as follows.

Lemma 1

Let q be a positive integer and χ a Dirichlet character \(\bmod\ q\). Then for any integers m and n, we have

$$S(m,n,\chi;q)\ll q^{1/2}(m,n,q)^{1/2}d(q), $$

where \(S(m,n,\chi;q)\) is defined by

$$S(m,n,\chi;q)=\sum_{a \bmod q}\chi(a)e \biggl( \frac {ma+n\overline{a}}{q} \biggr). $$

Proof

See Lemma 1 of [7]. □

Lemma 2

Let q be a positive integer, \(\chi_{0}\) be the principal Dirichlet character \(\bmod\ q\), ψ be a non-principal character modq, \(r_{1}\), \(r_{2}\) be integers with \(1\leqslant r_{1}, r_{2}\leqslant q-1\). Then we have

$$\bigl\vert G(r_{1},\psi)G(r_{2},\chi_{0}) \bigr\vert \leqslant q^{1/2}(r_{1},q) (r_{2},q). $$

Proof

By Lemma 2 of Chapter 1.2 in [11], we have

$$G(r_{2},\chi_{0})=\mu \biggl(\frac{q}{(r_{2},q)} \biggr) \phi(q)\phi ^{-1} \biggl(\frac{q}{(r_{2},q)} \biggr)\leqslant (r_{2},q), $$

where we have used the fact \(\phi(q)/\phi(t)\leqslant q/t\) if \(t \mid q\).

Note that ψ is a non-principal character \(\bmod\ q\), we only need to consider the following cases.

If \((r_{1},q)=1\), we have

$$\bigl\vert G(r_{1},\psi) \bigr\vert = \bigl\vert \overline{ \psi}(r_{1})G(1,\psi ) \bigr\vert = \bigl\vert G(1,\psi) \bigr\vert =q^{1/2}. $$

If \((r_{1},q)>1\), and ψ is a primitive character \(\bmod\ q\), we have

$$\bigl\vert G(r_{1},\psi) \bigr\vert = \bigl\vert \overline{ \psi}(r_{1})G(1,\psi ) \bigr\vert \le q^{1/2}. $$

If \((r_{1},q)>1\), and ψ is a non-primitive character \(\bmod\ q\), then Lemma 5 of Chapter 1.2 in [11] indicates that there exists one and only one \(q^{\ast} \) such that \(q^{\ast} \mid q\), with \(\chi^{\ast}\) the primitive character \(\bmod\ q^{\ast}\) corresponding χ. Thus

$$\begin{aligned} \bigl\vert G(r_{1},\psi) \bigr\vert \leqslant& \biggl\vert \overline{\chi }^{\ast} \biggl(\frac{r_{1}}{(r_{1},q)} \biggr) \chi^{\ast} \biggl(\frac{q}{q^{\ast}(r_{1},q)} \biggr)\mu \biggl(\frac{q}{q^{\ast}(r_{1},q)} \biggr) \phi(q)\phi^{-1} \biggl(\frac{q}{(r_{1},q)} \biggr)\tau \bigl( \chi^{\ast } \bigr) \biggr\vert \\ \leqslant &q^{1/2}(r_{1},q). \end{aligned}$$

Combining the above, we have

$$\bigl\vert G(r_{1},\psi)G(r_{2},\chi_{0}) \bigr\vert \leqslant q^{1/2}(r_{1},q) (r_{2},q). $$

 □

Lemma 3

Let \(q\ge3\) be an integer, χ, ψ be Dirichlet characters modq such that \(\psi\neq\chi_{0}\) and \(\psi\overline{\psi}=\chi_{0}\). Then we have the estimate

$$\mathop{\mathop{\sum_{\chi\bmod q}}_{\chi\neq\chi_{0}}}_{\chi \neq\overline{\psi}} G(r_{1},\chi\psi)G(r_{2},\chi)\ll\phi (q)q^{1/2}(r_{1},q)^{1/2}(r_{2},q)^{1/2}d(q). $$

Proof

Combining Lemmas 1 and 2, we have

$$\begin{aligned}& \mathop{\mathop{\sum_{\chi\bmod q}}_{\chi\neq \chi_{0}}}_{\chi\neq\overline{\psi}} G(r_{1},\chi\psi)G(r_{2},\chi) \\& \quad =\sum_{\chi\bmod q}G(r_{1},\chi \psi)G(r_{2},\chi) -G(r_{1},\psi)G(r_{2}, \chi_{0})-G(r_{1},\chi_{0})G(r_{2}, \overline {\psi}) \\& \quad =\sum_{\chi\bmod q}\sum_{a=1}^{q} \chi\psi (a)e \biggl(\frac{ar_{1}}{q} \biggr) \sum_{b=1}^{q} \chi(b)e \biggl( \frac{br_{2}}{q} \biggr) \\& \quad\quad{} -G(r_{1},\psi)G(r_{2},\chi_{0})-G(r_{1}, \chi _{0})G(r_{2},\overline{\psi}) \\& \quad =\phi(q) \mathop{{\sum}'}_{a=1}^{q} \psi(a) \mathop{\mathop{{\sum}'}_{b=1}}_{ab\equiv1 (\bmod q)}^{q}e \biggl(\frac{ar_{1}+br_{2}}{q} \biggr) \\& \quad =\phi(q)S(r_{1},r_{2},\psi;q) -G(r_{1}, \psi)G(r_{2},\chi _{0})-G(r_{1}, \chi_{0})G(r_{2},\overline{\psi}) \\& \quad \ll\phi (q)q^{1/2}(r_{1},r_{2},q)^{1/2}d(q)+q^{1/2}(r_{1},q) (r_{2},q) \\& \quad \ll\phi(q)q^{1/2}(r_{1},q)^{1/2}(r_{2},q)^{1/2}d(q). \end{aligned}$$

 □

Lemma 4

Let \(0<\rho\leqslant\frac{1}{2}\), \(x_{0},x_{1},\ldots, x_{k}\) be a sequence of real numbers such that

$$\langle x_{k}-x_{k'}\rangle \geqslant\rho,\quad\quad x_{k}\neq x_{k'}, $$

and \(\langle x_{0}\rangle =\min \{\langle x_{1}\rangle , \ldots, \langle x_{k}\rangle \}\). Then we have

$$\sum_{k=1}^{K}\frac{1}{\langle x_{k}\rangle }\ll \rho^{-1}\log(K+1). $$

Proof

See Lemma 2 of Chapter 5.1 in [11]. □

Lemma 5

Let \(q\ge3\) be an integer, ψ be a character \(\bmod \ q\), \(n\geqslant2\) be a fixed integer with \((n,q)=1\), l be an integer with \(1\leqslant l\leqslant n\). Then we have

$$\mathop{{\sum}'}_{a=1}^{q}\mathop{{ \sum}'}_{b=1}^{q}\psi(a) e \biggl( \frac{(a+b)l}{n} \biggr)\ll q^{1/2}\phi(q)d^{2}(q)\log q. $$

Proof

The relations

$$1\leqslant l\leqslant n, \quad\quad 1\leqslant r\leqslant q-1,\quad\quad (n,q)=1 $$

imply that

$$\frac{l}{n}-\frac{r}{q}\neq0. $$

And also

$$\psi(a)=\frac{1}{q}\sum_{r=1}^{q}G(r, \psi)e \biggl(-\frac{ar}{q} \biggr)= \frac{1}{q}\sum _{r=1}^{q-1}G(r,\psi)e \biggl(-\frac{ar}{q} \biggr). $$

Thus

$$\begin{aligned}& \mathop{{\sum}'}_{a=1}^{q}\mathop{{ \sum }'}_{b=1}^{q}\psi(a) e \biggl( \frac{(a+b)l}{n} \biggr) \\& \quad =\sum_{a=1}^{q}\psi(a)e \biggl( \frac{al}{n} \biggr) \mathop{{\sum}'}_{b=1}^{q}e \biggl(\frac{bl}{n} \biggr) \\& \quad =\sum_{a=1}^{q}\frac{1}{q} \sum _{r=1}^{q-1}G(r,\psi)e \biggl(- \frac{ar}{q} \biggr)e \biggl(\frac{al}{n} \biggr) \mathop{{\sum }'}_{b=1}^{q}e \biggl( \frac{bl}{n} \biggr) \\& \quad =\frac{1}{q}\sum_{r=1}^{q-1}G(r, \psi)\mathop{{\sum}'}_{b=1}^{q}e \biggl( \frac{bl}{n} \biggr) \sum_{a=1}^{q}e \biggl( \biggl(\frac{l}{n}-\frac{r}{q} \biggr)a \biggr) \\& \quad =\frac{1}{q}\mathop{{\sum}'}_{b=1}^{q}e \biggl(\frac{bl}{n} \biggr) \Biggl(\sum_{r=1}^{q-1} G(r,\psi)\frac{f(l,r,n,q)}{e (\frac{r}{q}-\frac{l}{n} )-1} \Biggr), \end{aligned}$$

where \(f(l,r,n,q)=1-e ( (\frac{l}{n}-\frac{r}{q} )q )\).

Apply the upper bound

$$\bigl\vert G(r,\psi) \bigr\vert \leqslant q^{1/2}(r,q), $$

we have

$$\begin{aligned} \sum_{r=1}^{q-1} G(r,\psi) \frac{f(l,r,n,q)}{e (\frac{r}{q}-\frac{l}{n} )-1} \ll& q^{1/2}\sum_{r=1}^{q-1} \frac{(r,q)}{\vert e (\frac{r}{q}-\frac{l}{n} )-1\vert } \\ \ll& q^{1/2}\sum_{r=1}^{q-1} \frac{(r,q)}{\vert \sin\pi (\frac{r}{q}-\frac{l}{n} )\vert } \ll q^{1/2}\sum_{r=1}^{q-1} \frac{(r,q)}{\langle \frac {r}{q}-\frac{l}{n}\rangle } \\ =&q^{1/2}\mathop{\mathop{\sum}_{d\mid q}}_{d< q} \mathop{\mathop{\sum }_{r\leqslant q-1}}_{(r,q)=d} \frac{d}{\langle \frac{r}{q}-\frac{l}{n}\rangle }=q^{1/2}\mathop {\mathop{\sum}_{d\mid q}}_{d< q}d \mathop{\mathop{\sum}_{m\leqslant\frac{q-1}{d}}}_{(m,q)=1}\frac {1}{\langle \frac{md}{q}-\frac{l}{n}\rangle } \\ =&q^{1/2}\mathop{\mathop{\sum}_{d\mid q}}_{d< q}d \sum_{k\mid q}\mu(k)\sum_{m\leqslant\frac{q-1}{kd}} \frac{1}{\langle \frac{mkd}{q}-\frac{l}{n}\rangle }. \end{aligned}$$

Now write \(\frac{k}{q/d}=\frac{h_{0}}{q_{0}}\), where \(q_{0}\geqslant 1\), \((h_{0},q_{0})=1\), we have \(\frac{q}{kd}=\frac{q_{0}}{h_{0}}\leqslant q_{0}\leqslant \frac{q}{d}\). Then Lemma 4 implies

$$\biggl\langle \frac{m_{i}kd}{q}-\frac{m_{j}kd}{q} \biggr\rangle = \biggl\langle \frac {(m_{i}-m_{j})h_{0}}{ q_{0}} \biggr\rangle \geqslant\frac{1}{q_{0}} \quad \text{if } i\neq j, 1\leqslant i, j\leqslant\frac{q-1}{kd}. $$

So we get

$$\begin{aligned} \sum_{r=1}^{q-1} G(r,\psi) \frac{f(l,r,n,q)}{e (\frac{r}{q}-\frac{l}{n} )-1} \ll &q^{1/2}\mathop{\mathop{\sum}_{d\mid q}}_{d< q}d \sum_{k\mid q}q_{0}\log \biggl( \frac{q-1}{kd}+1 \biggr) \\ \ll& q^{1/2}\mathop{\mathop{\sum}_{d\mid q}}_{d< q}d \sum_{k\mid q}\frac {q}{d}\log q \ll q^{3/2}d^{2}(q)\log q. \end{aligned}$$
(2.1)

Thus

$$\mathop{{\sum}'}_{a=1}^{q}\mathop{{ \sum}'}_{b=1}^{q}\chi_{1}(a) e \biggl(\frac{(a+b)l}{n} \biggr) \ll q^{1/2}\phi(q)d^{2}(q) \log q. $$

 □

3 Proof of the theorem

In this section, we shall complete the proof of the theorem.

Proof of the theorem

From the orthogonality relation for Dirichlet characters \(\bmod\ q\) and the trigonometric sum identity, we can get

$$\begin{aligned} \sum_{a\in\mathcal{C}(1,q)}\psi (a) =&\sum _{a=1}^{q}\psi(a)- \mathop{\mathop{\mathop{{\sum }}_{a=1}}_{n\mid(a+\overline {a})}}^{q}\psi(a) \\ =&\sum_{a=1}^{q}\psi(a)- \mathop{ \mathop{\mathop{{\sum}'}_{a=1}^{q} \mathop{{\sum }'}_{b=1}^{q}}_{n\mid(a+b)}}_{ab\equiv1(\bmod q)} \psi(a) \\ =&-\frac{1}{\phi(q)}\sum_{\chi\bmod q}\mathop{\mathop{{ \sum }'}_{a=1}^{q}\mathop{{\sum }'}_{b=1}^{q}}_{n\mid(a+b)}\psi(a)\chi (ab) \\ =&-\frac{1}{n\phi(q)}\sum_{\chi\bmod q}\mathop{{\sum }'}_{a=1}^{q}\mathop{{\sum }'}_{b=1}^{q} \psi(a)\chi(ab)\sum _{l=1}^{n}e \biggl(\frac{(a+b)l}{n} \biggr) \\ =&-\frac{1}{n\phi(q)}\mathop{\mathop{\sum_{\chi\bmod q}}_{\chi \neq\chi_{0}}}_{\chi\neq\overline{\psi}} \mathop{{\sum }'}_{a=1}^{q}\mathop{{ \sum }'}_{b=1}^{q} \psi(a)\chi(ab)\sum _{l=1}^{n}e \biggl(\frac{(a+b)l}{n} \biggr) \\ &{}-\frac{1}{n\phi(q)}\sum_{l=1}^{n} \mathop{{\sum }'}_{a=1}^{q}\mathop{{\sum }'}_{b=1}^{q} \psi(a)e \biggl( \frac{(a+b)l}{n} \biggr) \\ &{} -\frac{1}{n\phi(q)}\sum_{l=1}^{n} \mathop{{\sum}'}_{a=1}^{q}\mathop {{ \sum }'}_{b=1}^{q} \overline{\psi}(b)e \biggl(\frac{(a+b)l}{n} \biggr) \\ :=&-E_{1}-E_{2}-E_{3}. \end{aligned}$$

First of all, we shall estimate \(E_{1}\). Making use of Lemma 3, we get

$$\begin{aligned} E_{1} =&\frac{1}{n\phi(q)}\mathop{\mathop{\sum _{\chi\bmod q}}_{\chi\neq\chi_{0}}}_{\chi\neq\overline{\psi}}\mathop{{\sum }'}_{a=1}^{q}\mathop{{\sum}'}_{b=1}^{q} \psi(a)\chi(ab)\sum_{l=1}^{n}e \biggl( \frac{(a+b)l}{n} \biggr) \\ =&\frac{1}{n\phi(q)}\mathop{\mathop{\sum_{\chi\bmod q}}_{\chi\neq\chi_{0}}}_{\chi\neq\overline{\psi}} \sum_{l=1}^{n}\sum _{a=1}^{q}\chi\psi(a)e \biggl(\frac {al}{n} \biggr) \sum_{b=1}^{q}\chi(b)e \biggl( \frac{bl}{n} \biggr) \\ =&\frac{1}{n\phi(q)}\mathop{\mathop{\sum_{\chi\bmod q}}_{\chi\neq\chi_{0}}}_{\chi\neq\overline{\psi}} \sum_{l=1}^{n}\sum _{a=1}^{q}\frac{1}{q}\sum _{r_{1}=1}^{q-1}G(r_{1},\chi\psi) e \biggl(- \frac{ar_{1}}{q} \biggr)e \biggl(\frac{al}{n} \biggr) \\ &{} \times\sum_{b=1}^{q} \frac{1}{q} \sum_{r_{2}=1}^{q-1}G(r_{2}, \chi) e \biggl(-\frac{br_{2}}{q} \biggr)e \biggl(\frac{bl}{n} \biggr) \\ =&\frac{1}{n\phi(q)q^{2}}\mathop{\mathop{\sum_{\chi \bmod q}}_{\chi\neq\chi_{0}}}_{\chi\neq\overline{\psi}} \sum_{l=1}^{n}\sum _{r_{1}=1}^{q-1}G(r_{1},\chi\psi) \sum _{r_{2}=1}^{q-1}G(r_{2},\chi) \\ & {} \times\sum_{a=1}^{q}e \biggl( \biggl( \frac{l}{n}- \frac{r_{1}}{q} \biggr)a \biggr)\sum _{b=1}^{q}e \biggl( \biggl(\frac{l}{n}- \frac{r_{2}}{q} \biggr)b \biggr) \\ =&\frac{1}{n\phi(q)q^{2}}\sum_{l=1}^{n} \sum _{r_{1}=1}^{q-1}\sum_{r_{2}=1}^{q-1} \frac {f_{1}(l,r_{1},n,q)f_{2}(l,r_{2},n,q)}{ (e (\frac{l}{n}-\frac{r_{1}}{q} )-1 ) (e (\frac{l}{n}-\frac{r_{2}}{q} )-1 )} \\ &{} \times\mathop{\mathop{\sum_{\chi\bmod q}}_{\chi\neq\chi_{0}}}_{\chi\neq\overline{\psi}}G(r_{1}, \chi\psi)G(r_{2},\chi) \\ \ll&\frac{1}{\phi(q)q^{2}}\sum_{l=1}^{n} \sum_{r_{1}=1}^{q-1}\sum _{r_{2}=1}^{q-1}\frac {\phi(q)q^{1/2}(r_{1},q)^{1/2}(r_{2},q)^{1/2}d(q)}{ \vert e (\frac{l}{n}-\frac{r_{1}}{q} )-1\vert \vert e (\frac{l}{n}-\frac{r_{2}}{q} )-1\vert } \\ =&\frac{d(q)}{q^{3/2}}\sum_{l=1}^{n} \sum _{r_{1}=1}^{q-1}\sum_{r_{2}=1}^{q-1} \frac {(r_{1},q)^{1/2}(r_{2},q)^{1/2}}{ \vert e (\frac{l}{n}-\frac{r_{1}}{q} )-1\vert \vert e (\frac{l}{n}-\frac{r_{2}}{q} )-1\vert } \\ \ll&\frac{d(q)}{q^{3/2}}\sum_{l=1}^{n} \Biggl(\sum_{r=1}^{q-1}\frac{(r,q)^{1/2}}{ \vert e (\frac{l}{n}-\frac{r}{q} )-1\vert } \Biggr)^{2}. \end{aligned}$$

Similar to (2.1), we have

$$\sum_{r=1}^{q-1}\frac{(r,q)^{1/2}}{ \vert e (\frac{l}{n}-\frac{r}{q} )-1\vert } \ll \mathop{\mathop{\sum}_{d\mid q}}_{d< q}d^{1/2} \sum _{k\mid q}\frac {q}{d}\log q =q\log q\mathop{ \mathop{\sum}_{d\mid q}}_{d< q}d^{-1/2}\sum _{k\mid q}1 \ll qd^{2}(q)\log q. $$

Then

$$\begin{aligned} E_{1}\ll\frac{d(q)}{q^{3/2}}q^{2}d^{4}(q) \log ^{2}q=q^{1/2}d^{5}(q)\log^{2}q. \end{aligned}$$
(3.1)

Second, we estimate \(E_{2}\). By Lemma 5, we have

$$\begin{aligned} E_{2}\ll\frac{1}{\phi(q)}q^{1/2} \phi(q)d^{2}(q)\log q=q^{1/2}d^{2}(q)\log q. \end{aligned}$$
(3.2)

In the same way we can get the estimate

$$\begin{aligned} E_{3}\ll q^{1/2}d^{2}(q)\log q. \end{aligned}$$
(3.3)

Combining (3.1), (3.2), and (3.3), we obtain the result. □