# show that $\sum_{n \leq z} \frac{\tau(n)}{n} = \frac{1}{2} \log^2 z + c_2 \log z + c_3 + O(\sqrt[4]{z})$

I've been reading through Atle Selberg's "Elementary" proof of the Prime Number Theorem. That seems to be an ironic usage of the word. A lot of discussions focus on the Selberg symmetry formula:

$$\sum_{pq \leq x} \log p \, \log q + \sum_{p \leq x} \log^2 p = 2x \log x + O(x)$$

In order to prove these results he uses these "well-known" formulas that that tell part of the story:

$$\sum_{n \leq x} \frac{1}{n} = \log z + c_1 + O(\sqrt[4]{z})$$

Except for the error term this seems pretty clear. $c_1$ is the Euler-Mascheroni constant.

$$\sum_{n \leq z} \frac{\tau(n)}{n} = \frac{1}{2} \log^2 z + c_2 \log z + c_3 + O(\sqrt[4]{z})$$

How is this second formula proven?

It's a bit peculiar that the error term $O(\sqrt[4]{z})$ may be asymptotically larger than the given main terms. Let's use the better and well-known

$$\sum_{n \leqslant x} \frac{1}{n} = \log x + \gamma + O(x^{-1})$$

to get a better approximation of $\sum \frac{\tau(n)}{n}$. First, we get an expansion of the summatory divisor function,

\begin{align} T(x) &= \sum_{n \leqslant x} \tau(n) \\ &= \sum_{n \leqslant x} \sum_{d\mid n} 1 \\ &= \sum_{d \leqslant x} \biggl\lfloor \frac{x}{d}\biggr\rfloor \\ &= \sum_{d \leqslant x} \sum_{k \leqslant x/d} 1 \\ &= \sum_{\substack{d,k \\ dk \leqslant x}} 1 \\ &= 2\sum_{\substack{d \leqslant k \\ dk \leqslant x}} 1 - \sum_{\substack{d = k \\ dk \leqslant x}} 1 \\ &= 2\sum_{d \leqslant \sqrt{x}} \biggl( \biggl\lfloor\frac{x}{d}\biggr\rfloor - (d-1)\biggr) - \lfloor \sqrt{x}\rfloor \\ &= 2 \sum_{d \leqslant \sqrt{x}} \biggl\lfloor\frac{x}{d}\biggr\rfloor - \lfloor\sqrt{x}\rfloor(\lfloor \sqrt{x}\rfloor - 1) - \lfloor \sqrt{x}\rfloor \\ &= 2x\sum_{d\leqslant \sqrt{x}} \frac{1}{d} - x - 2\sum_{d\leqslant \sqrt{x}} \biggl(\frac{x}{d} - \biggl\lfloor \frac{x}{d}\biggr\rfloor\biggr) + \bigl(x - \lfloor \sqrt{x}\rfloor^2\bigr) \\ &= 2x\bigl(\log \sqrt{x} + \gamma + O(x^{-1/2})\bigr) - x + O(\sqrt{x}) \\ &= x \log x + (2\gamma - 1) x + O(\sqrt{x}). \end{align}

Then, by the Abel sum formula, we have

\begin{align} \sum_{n \leqslant z} \frac{\tau(n)}{n} &= \frac{T(z)}{z} + \int_1^z \frac{T(t)}{t^2}\,dt \\ &= \log z + (2\gamma-1) + O(x^{-1/2}) + \int_1^z \frac{t\log t + (2\gamma-1)t + O(\sqrt{t})}{t^2}\,dt \\ &= \log z + (2\gamma-1) + O(x^{-1/2}) + \frac{1}{2}\log^2 z + (2\gamma-1)\log z + \int_1^z O(t^{-3/2})\,dt \\ &= \frac{1}{2}\log^2 z + 2\gamma \log z + (2\gamma-1) + C + O(z^{-1/2}), \end{align}

where

$$C = \int_1^\infty \frac{T(t) - t\log t - (2\gamma-1)t}{t^2}\,dt = \int_1^\infty \frac{O(\sqrt{t})}{t^2}\,dt = \int_1^z \frac{O(\sqrt{t})}{t^2}\,dt + O(z^{-1/2}).$$