# A logarithmic estimate for harmonic sums and the digamma function, with an application to the Dirichlet divisor problem

## Abstract

Let $$H_{n} = \sum_{r=1}^{n} 1/r$$ and $$H_{n}(x) = \sum_{r=1}^{n} 1/(r+x)$$. Let $$\psi(x)$$ denote the digamma function. It is shown that $$H_{n}(x) + \psi(x+1)$$ is approximated by $$\frac{1}{2}\log f(n+x)$$, where $$f(x) = x^{2} + x + \frac{1}{3}$$, with error term of order $$(n+x)^{-5}$$. The cases $$x = 0$$ and $$n = 0$$ equate to estimates for $$H_{n} - \gamma$$ and $$\psi(x+1)$$ itself. The result is applied to determine exact bounds for a remainder term occurring in the Dirichlet divisor problem.

## Introduction and summary of results

Write $$H_{n}$$ for the harmonic sum $$\sum_{r=1}^{n} \frac{1}{r}$$. The following well-known estimation can be established by an Euler–Maclaurin summation, or by the logarithmic and binomial series:

$$H_{n} - \gamma= \log n + \frac{1}{2n} - \frac{1}{12n^{2}} + r_{n},$$
(1)

where γ is Euler’s constant and

$$0 < r_{n} \leq\frac{1}{120n^{4}}.$$

Since $$\log(n + \frac{1}{2}) = \log n + \frac{1}{2n} + O( \frac{1}{n^{2}})$$, it is a natural idea to absorb the term $$\frac{1}{2n}$$ into the logarithmic term and compare $$H_{n} - \gamma$$ directly with $$\log(n+ \frac{1}{2})$$. This was done by De Temple [6]: he showed that

$$H_{n} - \gamma= \log\biggl(n +\frac{1}{2}\biggr) + \frac{1}{24(n+ \frac{1}{2})^{2}} - r_{n},$$
(2)

where

$$\frac{7}{960(n+1)^{4}} \leq r_{n} \leq\frac{7}{960n^{4}}.$$

(We will repeatedly re-use the notation $$r_{n}$$ for the remainder term in estimations like this, with a new meaning each time.)

Negoi [9] demonstrated that the $$n^{-2}$$ term can be absorbed into the log term by considering $$\log h(n)$$, where $$h(n) = n + \frac{1}{2}+ \frac{1}{24n}$$. His result is

$$H_{n} - \gamma= \log h(n) - r_{n},$$
(3)

where $$\frac{1}{48}(n+1)^{-3} \leq r_{n} \leq\frac{1}{48}n^{-3}$$. Numerous more recent articles have developed this process further. For example, Chen and Mortici [3] show that

$$H_{n} - \gamma= \log \biggl( n + \frac{1}{2}+ \frac{1}{24n} - \frac{1}{48n ^{2}} + \frac{23}{5760n^{3}} \biggr) + O\bigl(n^{-5}\bigr).$$
(4)

Further variations and extensions are given, for example, in [7] and [4], and in other references listed in these papers. One natural extension is the replacement of $$H_{n} - \gamma$$ by $$\psi(x+1)$$, where $$\psi(x)$$ is the digamma function $$\varGamma'(x)/ \varGamma(x)$$, since $$H_{n} - \gamma= \psi(n+1)$$.

A slightly different approach, which has proved quite effective, is to compare $$H_{n} - \gamma$$ or $$\psi(x+1)$$ with expressions of the form $$\frac{1}{2}\log f(n)$$. Using no more than the elementary inequalities $$H_{n} - \gamma\leq\log n + \frac{1}{2n}$$ and $$e^{x} \leq1 + x + x ^{2}$$, it is easily shown that $$H_{n} - \gamma\leq\frac{1}{2}\log(n^{2} + n + 1)$$. With $$h(n)$$ as in (3), we have $$h(n)^{2} = n^{2} + n + \frac{1}{3} + O(\frac{1}{n})$$, suggesting that the right comparison is with $$f(n) = n^{2} + n + \frac{1}{3}$$. Indeed, with $$f(n)$$ defined in this way, Batir [2] and Lu [5] have shown, by different methods, that

$$H_{n} - \gamma= \frac{1}{2} \log f(n) - r_{n},$$
(5)

where $$r_{n} \sim1/(180n^{4})$$. Lu obtained (5) as one case of a rather complicated analysis extending to further terms and parameters.

Our objective here is to refine and extend (5) by considering the sum

$$H_{n}(x) = \sum_{r=1}^{n} \frac{1}{r+x},$$
(6)

To identify the limit of $$H_{n}(x) - \log n$$, recall Euler’s limit formula for the Gamma function: this can be written as $$\varGamma(x+1) = \lim_{n\to\infty} G_{n}(x+1)$$, where

$$G_{n}(x+1) = \frac{n^{x}(n+1)!}{(x+1) \ldots(x+n)},$$

from which it follows that $$\lim_{n\to\infty} [H_{n}(x) - \log n] = -\psi(x+1)$$. (No further facts about $$\psi(x)$$ are needed for our purposes.) We compare the difference $$H_{n}(x) + \psi(x+1)$$ with $$\frac{1}{2}\log f(n+x)$$. The case $$x = 0$$ reproduces (5), while the case $$n = 0$$ (with $$H_{0}(x) =0$$) gives a similar estimate for $$\psi(x+1)$$. Unlike [2] and [5], we give explicit upper and lower bounds for the error term, which we will require in the subsequent application. The exact statement is as follows.

### Theorem 1

Let $$n \geq1$$ and $$x > -1$$, or $$n = 0$$ and $$x > 0$$, and let $$H_{n}(x)$$ be defined by (6). Let $$f(x) = x^{2} + x + \frac{1}{3}$$. Then

$$H_{n}(x) + \psi(x+1) = \frac{1}{2} \log f(n+x) - r(n,x),$$
(7)

where

$$\frac{1}{180(n+x+1)^{4}} \leq r(n,x) \leq\frac{1}{180 (n+x)^{4}}.$$
(8)

In particular,

$$H_{n} - \gamma= \frac{1}{2}\log f(n) - r_{n},$$
(9)

where

$$\frac{1}{180(n+1)^{4}} \leq r_{n} \leq\frac{1}{180 n^{4}}.$$
(10)

Also, for $$x > 0$$,

$$\psi(x+1) = \frac{1}{2}\log f(x) - r(x),$$
(11)

where

$$\frac{1}{180(x+1)^{4}} \leq r(x) \leq\frac{1}{180 x^{4}}.$$
(12)

Our proof, given in Sect. 2, is a development of De Temple’s original method.

Note that the difference between the upper and lower bounds in (10) is less than $$1/45n^{5}$$. Of course, (9) is actually a special case of (11).

The case $$x = -\frac{1}{2}$$ in (7) leads to the following estimation of sums of odd reciprocals (which could not be derived from (9)). The proof is very short, so we include it here.

### Corollary 1

Let $$U_{n} = \sum_{r=1}^{n} \frac{1}{2r-1}$$. Then

$$U_{n} - \frac{1}{2} \gamma- \log2 = \frac{1}{4} \log \biggl(n^{2} + \frac{1}{12}\biggr) - r_{n},$$

where

$$\frac{1}{360(n+ \frac{1}{2})^{4}} \leq r_{n} \leq \frac{1}{360(n- \frac{1}{2})^{4}}.$$

### Proof

Note that $$2U_{n} = H_{n}(-\frac{1}{2})$$. Also, $$2U_{n} = 2H_{2n} - H_{n}$$, from which it follows easily that $$-\psi(\frac{1}{2}) = \lim_{n\to \infty }[2U_{n} - \log n] = \gamma+ 2\log2$$. Finally, $$f(n- \frac{1}{2}) = n ^{2} + \frac{1}{12}$$. □

Theorem 1 has a rather surprising application to an expression that arises in the Dirichlet divisor problem. Denote the divisor function by $$\tau(n)$$ and its summation function $$\sum_{n \leq x} \tau(n)$$ by $$T(x)$$. Write

$$F(x) = x \log x + (2\gamma-1)x$$

and

$$T(x) = F(x) + \Delta(x).$$

The most basic form of Dirichlet’s theorem (e.g. [1, p. 59]) states that $$\Delta(x) = O(x^{1/2})$$. The problem of determining the true order of magnitude of $$\Delta(x)$$ is the “Dirichlet divisor problem”. Denote by $$\theta_{0}$$ the infimum of numbers θ such that $$\Delta(x) = O(x^{\theta})$$. It was already shown by Voronoi in 1903 that $$\theta_{0} \leq\frac{1}{3}$$ (e.g. see [10, Sect. 1.6.4]). The estimate has been gradually reduced in a long series of studies: the current best value [8] is $$\theta_{0} \leq\frac{131}{416}$$.

Write $$[x]$$ for the integer part of x and let

$$B(x) = x - [x] - \frac{1}{2},$$

the 1-periodic extension of the function $$x - \frac{1}{2}$$ on $$[0, 1)$$. Further, let

$$S(x) = 2 \sum_{j \leq x^{1/2}} B \biggl( \frac{x}{j} \biggr).$$

Note that $$|B(x)| \leq\frac{1}{2}$$, and hence $$|S(x)| \leq [x^{1/2}]$$, for all $$x > 0$$. A key, if small, step in the proof of Voronoi’s theorem and later refinements is the statement

$$\Delta(x) = -S(x) + q(x),$$
(13)

where $$q(x)$$ is bounded. A version of the usual proof can be found in [10, Sect. 1.6.4]; if scrutinised carefully, it gives the bound 3 for $$|q(x)|$$. This is quite good enough for the purpose of proving Voronoi’s theorem: the serious work is the estimation of $$S(x)$$ by exponential sums. However, it is still of some interest to determine the true bounds for $$q(x)$$, along with some other facts about its nature. We will see that $$q(x)$$ is continuous at integers, and that (9), together with (1), is exactly what is needed to establish:

### Theorem 2

With $$q(x)$$ defined as above, we have, for all $$x \geq1$$,

$$- \frac{1}{6} < q(x) < \frac{1}{3} .$$
(14)

Both bounds are optimal.

## The proof of Theorem 1

The key step is the following lemma.

### Lemma 1

Let $$f(x) = x^{2} + x + \frac{1}{3}$$. Then, for all $$x \geq1$$,

$$\log f(x) - \log f(x-1) = \frac{2}{x} - \delta(x),$$
(15)

where

$$\frac{2}{45x^{5}} < \delta(x) < \frac{2}{45(x - \frac{1}{2})^{5}}.$$
(16)

### Proof

We start with $$f(x) = x^{2} + x + c$$ and allow the choice of c to emerge from the reasoning. Let $$\delta(x)$$ be defined by (15). Now $$f(x)/f(x-1) \to1$$, and hence $$\delta(x) \to0$$, as $$x \to\infty$$. So $$\delta(x) = - \int_{x}^{\infty}\delta'(t) \,dt$$ for all $$x > 0$$. Now

\begin{aligned} - \delta'(t) & = \frac{2t+1}{f(t)} - \frac{2t-1}{f(t-1)} + \frac{2}{t ^{2}} \\ & = \frac{G(t)}{t^{2} f(t) f(t-1)}, \end{aligned}

where

\begin{aligned} G(t) & = t^{2}(2t+1) \bigl(t^{2} - t +c\bigr) - t^{2}(2t-1) \bigl(t^{2} + t + c\bigr) + 2\bigl(t ^{2} + t + c\bigr) \bigl(t^{2} - t + c\bigr) \\ & = -t^{2} \bigl(2t^{2} - 2c\bigr) + 2\bigl[ t^{4} + (2c-1)t^{2} + c^{2}\bigr] \\ & = 2(3c - 1)t^{2} + 2c^{2}. \end{aligned}

To eliminate the $$t^{2}$$ term, we now choose $$c = \frac{1}{3}$$, so that $$G(t) = \frac{2}{9}$$ and

$$-\delta'(t) = \frac{2}{9 t^{2} f(t) f(t-1)}.$$

Now $$f(t) f(t-1) = t^{4} - \frac{1}{3} t^{2} + \frac{1}{9} < t^{4}$$ for $$t \geq1$$, so

$$\delta(x) > \int_{x} ^{\infty}\frac{2}{9t^{6}} \,dt = \frac{2}{45x ^{5}}$$

for $$x \geq1$$. On the other hand, $$f(t) > f(t-1) > (t - \frac{1}{2})^{2}$$, hence

$$\delta(x) < \int_{x}^{\infty}\frac{2}{9(t- \frac{1}{2})^{6}} \,dt = \frac{2}{45(x - \frac{1}{2})^{5}}.$$

□

### Proof of Theorem 1

Apply the identity (15) to $$r+x$$ for $$1 \leq r \leq n$$ and add: we find

$$\log f(n+x) - \log f(x) = 2H_{n}(x) - \sum _{r=1}^{n} \delta(r+x),$$

equivalently

$$2H_{n}(x) - \log f(n+x) = -\log f(x) + \sum _{r=1}^{n} \delta(r+x).$$
(17)

Now $$f(n+x)/n^{2} \to1$$, so $$\log f(n+x) - 2 \log n \to0$$, as $$n \to\infty$$. Taking the limit in (17), we see that

$$-2\psi(x+1) = -\log f(x) + \sum_{r=1}^{\infty} \delta(r+x).$$
(18)

Now taking the difference, we have

$$2H_{n}(x) - \log f(n+x) + 2\psi(x+1) = -2r(n,x),$$

where

$$2r(n,x) = \sum_{r = n+1}^{\infty}\delta(r+x).$$

The condition $$x > -1$$ ensures that the inequality (16) applies to $$\delta(r+x)$$ for $$r \geq2$$. By integral estimation, we now have, for $$n \geq1$$,

$$r(n,x) \geq\sum_{r = n+1}^{\infty} \frac{1}{45(r+x)^{5}} > \int_{n+1} ^{\infty}\frac{1}{45(t+x)^{5}} \,dt = \frac{1}{180(n+x+1)^{4}}.$$

At the same time,

$$r(n,x) \leq\sum_{r = n+1}^{\infty} \frac{1}{45(r- \frac{1}{2}+x)^{5}}.$$

The function $$1/(t+x)^{5}$$ is convex, and convex functions $$h(t)$$ satisfy $$h(y -\frac{1}{2}) \leq\int_{y-1}^{y} h(t) \,dt$$, hence

$$r(n,x) \leq \int_{n}^{\infty}\frac{1}{45(t+x)^{5}} \,dt = \frac{1}{180(n+x)^{4}}.$$

For $$x > 0$$, the case $$n = 0$$ follows similarly from (18) (note that (16) now applies also to $$\delta(1+x)$$). □

### Note 1

The upper bounds for $$\delta(x)$$ in Lemma 1 and $$r(n,x)$$ in Theorem 1 can be slightly improved. One can verify that $$t^{2} f(t) f(t-1) \geq(t - \frac{1}{12})^{6}$$ where we previously used $$(t - \frac{1}{2})^{6}$$. This leads to $$\delta(x) < 2/[45(x - \frac{1}{12})^{5}]$$ and $$r(n,x) \leq1/[180 (n+x+ \frac{5}{12})^{4}]$$.

### Note 2

In principle, one could derive Stirling-type approximations to $$\log\varGamma(x)$$ and $$\varGamma(x)$$ from (11), but only in terms of the rather unpleasant antiderivative of $$\log f(x)$$.

## The remainder in the divisor problem

We return to the divisor problem. The starting point is Dirichlet’s hyperbola identity [1, p. 59]:

$$T(x) = 2 \sum_{j \leq x^{1/2}} \biggl[ \frac{x}{j} \biggr] - \bigl[x^{1/2}\bigr]^{2}.$$
(19)

With our previous notation, note that

$$T(x) + S(x) = F(x) + q(x).$$

Write $$I_{n} = [n^{2}, (n+1)^{2}]$$.

### Lemma 2

For $$x \in I_{n}$$,

$$q(x) = xH_{n} - F(x) - n(n+1).$$
(20)

The function $$q(x)$$ is continuous for all $$x \geq1$$, and concave on each interval $$I_{n}$$.

### Proof

We work with $$T(x) + S(x)$$. For $$n^{2} \leq x < (n+1)^{2}$$, we have by (19)

\begin{aligned} T(x) & = 2 \sum_{j=1}^{n} \biggl( \frac{x}{j} - B \biggl( \frac{x}{j} \biggr) - \frac{1}{2} \biggr) - n^{2} \\ & = 2xH_{n} - S(x) - n - n^{2}, \end{aligned}

which equates to (20). We check that this remains valid at $$x = (n+1)^{2}$$. By what we have just shown, with n replaced by $$n+1$$,

\begin{aligned} T\bigl[(n+1)^{2}\bigr] + S\bigl[(n+1)^{2}\bigr] & = 2H_{n+1} (n+1)^{2} - (n+1) (n+2) \\ & = 2H_{n} (n+1)^{2} + 2(n+1) - (n+1) (n+2) \\ & = 2H_{n} (n+1)^{2} - n(n+1), \end{aligned}

agreeing with (20). Hence $$F(x) + q(x)$$, and consequently $$q(x)$$ itself, is continuous for all $$x \geq1$$. Also, $$q'(x) = 2H_{n} - F'(x) = 2H _{n} - \log x - 2\gamma$$, which is decreasing, so $$q(x)$$ is concave on $$I_{n}$$. □

So in fact $$F(x) + q(x)$$ is linear on $$I_{n}$$. For example,

$$F(x) + q(x) = \textstyle\begin{cases} 2x-2 & \mbox{for } 1 \leq x \leq4, \\ 3x-6 & \mbox{for } 4 \leq x \leq9. \end{cases}$$

The reason for continuity of $$T(x) + S(x)$$ is easily seen directly. At non-square integers k, $$T(x)$$ increases by $$\tau(k)$$. Meanwhile, for each divisor j of k with $$j < k^{1/2}$$, $$[x/j]$$ increases by 1, so $$B(x/j)$$ decreases by 1. There are $$\frac{1}{2}\tau(k)$$ such divisors j, so $$S(x)$$ decreases by $$\tau(k)$$. At square integers $$k = n^{2}$$, the new term $$2B(k/n) = -1$$ enters the sum, so again the decrease in $$S(x)$$ is $$\tau(k)$$.

To determine the lower bound of $$q(x)$$, we consider $$q(n^{2})$$ and apply (1).

### Lemma 3

We have $$q(x) > - \frac{1}{6}$$ for all $$x \geq1$$. Further, $$q(n^{2}) \leq-\frac{1}{6} + \frac{1}{60n^{2}}$$, so $$\inf_{x\geq1} q(x)= -\frac{1}{6}$$.

### Proof

By (20) and (1) (with $$r_{n}$$ as in (1)),

\begin{aligned} q\bigl(n^{2}\bigr) & = 2n^{2} H_{n} - 2n^{2} \log n - (2\gamma-1)n^{2} - n - n^{2} \\ & = 2n^{2} (H_{n} - \log n - \gamma) - n \\ & = 2n^{2} \biggl( \frac{1}{2n} - \frac{1}{12n^{2}} + r_{n} \biggr) - n \\ & = - \frac{1}{6} + 2n^{2} r_{n}. \end{aligned}

So

$$-\frac{1}{6} < q\bigl(n^{2}\bigr) \leq- \frac{1}{6} + \frac{1}{60n^{2}}.$$

This applies also at $$(n+1)^{2}$$. Since $$q(x)$$ is concave on $$I_{n}$$, it follows that $$q(x) > - \frac{1}{6}$$ throughout this interval. □

Finally, we apply (9) and (10) to identify the upper bound.

### Proof of the upper bound in Theorem 2

Let $$x_{n}$$ be the point where $$q(x)$$ attains its maximum in $$I_{n}$$. Since $$q'(x) = 2H_{n} - \log x - 2\gamma$$, we have $$\log x_{n} = 2H_{n} - 2\gamma$$, hence the maximum value is

\begin{aligned} q(x_{n}) & = 2H_{n} x_{n} - F(x_{n}) - n(n+1) \\ & = (\log x_{n} + 2\gamma)x_{n} - F(x_{n}) - n(n+1) \\ & = x_{n} - n(n+1). \end{aligned}
(21)

By (9) and (10) (using only $$r_{n} > 0$$), we have $$\log x_{n} < \log f(n)$$, so $$x_{n} < f(n) = n(n+1) + \frac{1}{3}$$, hence $$q(x_{n}) < \frac{1}{3}$$.

We show that, conversely,

$$q(x_{n}) > \frac{1}{3} - \frac{1}{45n^{2}}$$

for $$n \geq2$$, so that $$\sup_{x \geq1} q(x) = \frac{1}{3}$$. By (21), this is equivalent to $$x_{n} > f(n) - \frac{1}{45n^{2}}$$. By (10),

$$\log x_{n} = 2H_{n} - 2\gamma\geq\log f(n) - \frac{1}{90n^{4}}.$$

Now using the inequality $$e^{-x} \geq1 - x$$, together with $$f(n) \leq2n^{2}$$, we have

$$x_{n} \geq f(n) e^{-1/90n^{4}} \geq f(n) \biggl( 1 - \frac{1}{90n^{4}} \biggr) \geq f(n) - \frac{1}{45n^{2}}.$$

□

## References

1. Apostol, T.M.: Introduction to Analytic Number Theory. Springer, Berlin (1976)

2. Batir, N.: Sharp bounds for the psi function and harmonic numbers. Math. Inequal. Appl. 14, 917–925 (2011)

3. Chen, C., Mortici, C.: New sequence converging towards the Euler–Mascheroni constant. Comput. Math. Appl. 64, 391–398 (2012)

4. Dawei, L.: Some new convergent sequences and inequalities of Euler’s constant. J. Math. Anal. Appl. 419, 541–552 (2014)

5. Dawei, L.: Some quicker classes of sequences convergent to Euler’s constant. Appl. Math. Comput. 232, 172–177 (2014)

6. De Temple, D.W.: A quicker convergence to Euler’s constant. Am. Math. Mon. 100, 468–470 (1993)

7. Elezovic, N.: Estimations of psi function and harmonic numbers. Appl. Math. Comput. 258, 192–205 (2015)

8. Huxley, M.N.: Exponential sums and lattice points III. Proc. Lond. Math. Soc. (3) 87, 591–609 (2003)

9. Negoi, T.: A faster convergence to Euler’s constant. Math. Gaz. 83, 487–489 (1999)

10. Tenenbaum, G.: Introduction to Analytic and Probabilistic Number Theory. Cambridge Univ. Press, Cambridge (1995)

Not applicable.

Not applicable.

## Author information

Authors

### Contributions

The author read and approved the final manuscript.

### Corresponding author

Correspondence to G. J. O. Jameson.

## Ethics declarations

### Competing interests

The author declares that he has no competing interests.

### Publisher’s Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

## Rights and permissions

Reprints and Permissions

Jameson, G.J.O. A logarithmic estimate for harmonic sums and the digamma function, with an application to the Dirichlet divisor problem. J Inequal Appl 2019, 151 (2019). https://doi.org/10.1186/s13660-019-2104-9

• Accepted:

• Published:

• DOI: https://doi.org/10.1186/s13660-019-2104-9

• 26D15
• 33B15
• 11N37

### Keywords

• Harmonic sum
• Euler’s constant
• Digamma function
• Divisor problem