Asymptotic formula for d(n)/n summation

I was trying to show $$\sum_{n \le x} \frac{d(n)}{n} = \frac{1}{2}\log(x)^2 + 2\gamma \log(x) + O(1)$$ where $d(n)$ is the number of divisors of $n$ and $\gamma$ is the Euler constant using the identity $$\sum_{n \le x}(f * g)(n) = \sum_{n \le x} f(n) G\left(\frac{x}{n}\right)$$ where $G(x) = \sum_{n \le x} g(x)$.

Edit I was using the wrong $f$,$g$ before. Here it is with different $f$,$g$.

For $f(n) = \frac{1}{n}$ and $g(n) = \frac{1}{n}$ this gives $\sum_{n \le x}\frac{d(n)}{n} = \sum_{a \le x} \sum_{b \le x/a}\frac{1}{ab}=\sum_{a \le x}\frac{1}{a}\left(\log(x/n) + \gamma + O(\frac{n}{x})\right)$ since $G(x) = \sum_{n \le x} \frac{1}{n} = \log(x) + \gamma + O(\frac{1}{x})$ by Euler's summation formula. Then apply Euler's summation formula again to get $- \frac{1}{2} \log(x/a)^2 + \gamma \log(x) + O(x^2)$ but this is still wrong.

I can't see at all what I am doing wrong here so it's probably really simple, I would really appreciate if someone could show how to do this or what I've done wrong. Thanks a lot.

-
Why do you think that $(f \ast g)(n) = d(n)/n$? – Sangchul Lee May 8 '11 at 4:20
You may use $f(n) = g(n) = 1/n$ to derive the estimation. – Sangchul Lee May 8 '11 at 4:48
I get your result by a lengthy summation, if necessary I can type it out. But you should know that you have convolution incorrect:  en.wikipedia.org/wiki/Dirichlet_convolution – Will Jagy May 8 '11 at 5:48
@Will: Yes, it is true. It follows from the estimate $\sum_{n \le x} d(n) = x\log x + (2\gamma -1)x + O(\sqrt{x})$. Apply Abel's identity with $f(t) = 1/t$ and you get the above. I believe this is even an exercise in Apostol's Analytic Number Theory book. – Aryabhata May 8 '11 at 6:12
@sos440, thanks - I tried using this but I still don't get the right answer. – quanta May 8 '11 at 10:50

Let's start at $$\sum_{n \leq x} \frac{d(n)}{n} = \sum_{n \leq x} \frac{1}{n} \left( \log \left( \frac{x}{n} \right) + \gamma + O\left( \frac{n}{x}\right) \right).$$ Proceeding, $$\begin{eqnarray*} & = & \sum_{n \leq x} \left( \frac{1}{n}(\log x + \gamma) - \frac{\log n}{n} + O\left( \frac{1}{x}\right) \right) \\ & = & (\log x + \gamma)(\log x + \gamma + O(1/x)) + O(1) - \sum_{n \leq x} \frac{\log n}{n} \\ & = & \log^2 x + 2\gamma \log x + O(1) - \sum_{n \leq x} \frac{\log n}{n}. \end{eqnarray*}$$ Since $f(x) = \log x / x$ is decreasing for large $x$, we may write $$\sum_{n \leq x} \frac{\log n}{n} = \int_{1}^{x} \frac{\log u}{u} \, du + O(1) = \frac{1}{2}\log^2 x + O(1),$$ which completes the calculation.
I don't think $f*g$ is actually $d(n)/n$ in your case. What might help would be to write
$\sum_{n \le x} \frac{d(n)}{n} = \sum_{n \le x} \sum_{a \, b = n} \frac{1}{n} = \sum_{a \, b \le x} \frac{1}{ab}$
This is the right way, we can actually show that the error term is $O(\log x/\sqrt{x})$. – Xiang Yu Apr 12 at 14:20