TITLE: The asymptotic expansion for the weighted sum of divisors $\sum_{n\leq x} \frac{d(n)}{n}$
QUESTION [10 upvotes]: I am trying to solve a problem about the divisor function. Let us call $d(n)$ the classical divisor function, i.e. $d(n)=\sum_{d|n}$ is the number of divisors of the integer $n$. It is well known that the sum of $d(n)$ over all positive integers from $n=1$ to $x$, when $x$ tends to infinity, is asymptotic to $$x \ln(x) + (2 \gamma-1) x + O(\sqrt{x})$$
I would like to calculate a similar asymptotic expression for the sum of $d(n)/n$, again calculated from $n=1$ to $x$ and for $x$ that tends to infinity. I have made some calculations and obtained the  formula 
$$1/2 (\ln(x))^2 + 2 \gamma \ln (x) + O(1)$$ 
where gamma is the Euler-Mascheroni constant. I am interested in the constant term of the expression, which seems to be around $0.48$. I suspect that it could correspond to $\gamma^2 - 2\gamma_1$,   where $\gamma_1$ is the first Stieltjes constant ($-0.072...$). Could someone confirm this to me? 
As an additional question, I would be very interested in obtaining similar asymptotic formulas, with explicitly given constant terms,  for the same sum of $d(n)/n$ calculated over all odd integers from $1$ to $x$, and for that calculated over all even integers from $1$ to $x$. 
Many thanks.

REPLY [2 votes]: I will do the case of the sum being restricted to even integers for the sake of completing the original problem as stated by the OP.
Start with $\Lambda(s)$ for $\sum_{n \; \text{odd}} d(n)/n^s$ which is
$$\Lambda(s) = \left(1-\frac{1}{2^s}\right)^2\zeta(s)^2.$$
It follows that for $\sum_{n \; \text{even}} d(n)/n^s$ we have
$$\Lambda(s) = \left(\frac{2}{2^s} + \frac{3}{2^{2s}} + \frac{4}{2^{3s}}
+ \cdots + \frac{k+1}{2^{ks}} + \cdots \right)
\left(1-\frac{1}{2^s}\right)^2\zeta(s)^2.$$
With the closed form of the sum we obtain
$$\Lambda(s) = \frac{1/2^s(2-1/2^s)}{(1-1/2^s)^2}
\left(1-\frac{1}{2^s}\right)^2\zeta(s)^2
= \frac{1}{2^s}\left(2-\frac{1}{2^s}\right)\zeta(s)^2.$$
It follows that the Dirichlet series for $\sum_{n \; \text{even}} d(n)/n/n^s$ is
$$\Lambda(s) =  \frac{1}{2^{s+1}}\left(2-\frac{1}{2^{s+1}}\right)\zeta(s+1)^2.$$
Now using the same technique as in the previous two cases we have
$$\operatorname{Res}
\left( \frac{1}{2^{s+1}}\left(2-\frac{1}{2^{s+1}}\right)\zeta(s+1)^2 
\frac{n^s}{s(s+1)}; s=0\right)= \frac{3}{8}\log^2 n \\
+ \left(\frac{3}{2}\gamma - \frac{1}{2}\log 2 - \frac{3}{4}\right) \log n
+ \frac{3}{4} (\gamma-1)^2 + \frac{1}{2}\log 2 -\gamma \log 2 - \frac{3}{2}\gamma_1.$$
Finally compute $q(n)-q(n-1)$ as in the previous two posts to get
$$\frac{3}{8}\log^2 n
+ \left(\frac{3}{2}\gamma - \frac{1}{2}\log 2\right) \log n
+ \frac{3}{4} \gamma^2 -\gamma \log 2 - \frac{3}{2}\gamma_1.$$
The remainder term is $\mathcal{O}(1/\sqrt{n})$ as before. What is very nice about this computation is that it is precisely the difference of the previous two results as predicted by Eric in his comment.
The Mellin integral converges because
$$ \frac{1}{\sqrt{2}} \left(2 - \frac{1}{\sqrt{2}}\right) \le
\left|\frac{1}{2^{s+1}}\left(2-\frac{1}{2^{s+1}}\right)\right| \le
 \frac{1}{\sqrt{2}} \left(2 + \frac{1}{\sqrt{2}}\right).$$