Compute $\lim_{n\to\infty} \left(\sum_{k=1}^n \frac{H_k}{k}-\frac{1}{2}(\ln n+\gamma)^2\right) $ Compute
$$\lim_{n\to\infty} \left(\sum_{k=1}^n \frac{H_k}{k}-\frac{1}{2}(\ln n+\gamma)^2\right) $$
where $\gamma$ - Euler's constant.
 A: We have 
\begin{align}
2\sum_{k=1}^n \frac{H_k}{k} &= 2\sum_{k=1}^n \sum_{j=1}^k \frac{1}{jk} \\
&= \sum_{k=1}^n \sum_{j=1}^k \frac{1}{jk} + \sum_{k=1}^n \sum_{j=1}^k \frac{1}{jk} \\
&= \sum_{k=1}^n \sum_{j=1}^k \frac{1}{jk} + \sum_{j=1}^n \sum_{k=j}^n \frac{1}{jk}, \text{ swapping the order of summation on the second sum}\\
&= \sum_{k=1}^n \sum_{j=1}^k \frac{1}{jk} + \sum_{k=1}^n \sum_{j=k}^n \frac{1}{jk}, \text{ changing variables on the second sum}\\
&= \sum_{k=1}^n \sum_{j=1}^n \frac{1}{jk} + \sum_{k=1}^n \frac{1}{k^2} \\
&= \left(\sum_{k=1}^n \frac{1}{k} \right)^2 + \sum_{k=1}^n \frac{1}{k^2} \\
&= H_n^2+ H^{(2)}_n. \\
\end{align}
Thus 
\begin{align*}
\lim_{n\to\infty} \left(\sum_{k=1}^n \frac{H_k}{k}-\frac{1}{2}(\log n+\gamma)^2\right) &= \lim_{n\to\infty} \frac{1}{2}\left(H_n^2+ H^{(2)}_n-(\log n+\gamma)^2\right) \\
&= \lim_{n\to\infty} \frac{1}{2}\left((\log n + \gamma)^2 + O(\log n/n) + H^{(2)}_n-(\log n+\gamma)^2\right) \\
&= \frac{1}{2}\lim_{n\to\infty} \left( H^{(2)}_n + O(\log n/n) \right) \\
&= \frac{1}{2}\lim_{n\to\infty} \sum_{k=1}^n \frac{1}{k^2}\\
&= \frac{\pi^2}{12}.
\end{align*}
