Inequality involving Euler-Mascheroni constant I would like to solve the following problem from 'Real Analysis and Foundations' by S. Krantz.
Let $a_n = 1+\frac{1}{2} + \frac{1}{3} + \cdots + \frac{1}{n} - \log{n}$ and $\gamma$ be the Euler-Mascheroni constant. Show that $$\vert a_n - \gamma \vert \le \frac{C}{n}$$ for some universal constant $C>0$.
I have no clue how to solve this problem. From searching various sites it seems that $C=\frac{1}{2}$ but I am not sure with this, too. Thanks in advance.
 A: From here we obtain the bounds
$$\frac{1}{2n+2} \leqslant a_n - \gamma \leqslant \frac{1}{2n}$$
Thus, if $a_n - \gamma \leqslant \frac{C}{n}$ then we must have $\frac{C}{n} \geqslant \frac{1}{2n+2}$ which implies for all $n$,
$$C\geqslant \frac{1}{2 + 2/n},$$
and $C = \frac{1}{2}$ is the smallest constant that works.
A: A self-contained approach. For any $n\geq 1$ we have $\frac{1}{n}=\int_{0}^{+\infty}e^{-nt}\,dt$ and $\log(n)=\int_{0}^{+\infty}\frac{e^{-t}-e^{-nt}}{t}\,dt$ by Frullani's theorem, hence $a_n=H_n-\log(n)$ can be represented as
$$ \int_{0}^{+\infty}\frac{1-e^{-nt}}{e^t-1}-\frac{e^{-t}-e^{-nt}}{t}\,dt=\int_{0}^{+\infty}\left(\frac{1}{e^t-1}-\frac{1}{te^t}\right)\,dt-\int_{0}^{+\infty}\left(\frac{1}{e^t-1}-\frac{1}{t}\right)e^{-nt}\,dt $$
hence
$$ a_n-\gamma=\int_{0}^{+\infty}\left(\frac{1}{t}-\frac{1}{e^t-1}\right)e^{-nt}\,dt = \int_{0}^{+\infty}g(t) e^{-nt}. \tag{1}$$
We already know that the RHS goes to zero as $n\to+\infty$, and the positive function $g(t)$


*

*Is bounded by $\frac{1}{2}e^{-t/6}$ on the interval $(0,6]$

*Is bounded by $\frac{1}{6}$ on the interval $(6,+\infty)$
hence
$$ 0\leq a_n-\gamma \leq \frac{3}{6n+1} \tag{2}$$
for any $n\geq 2$. By applying integration by parts to the RHS of $(1)$ you  may similarly show that
$$ H_n = \log(n) + \gamma + \frac{1}{2n}-\frac{1-o(1)}{12n^2}.\tag{3} $$
The same can be proved through creative telescoping or through the Euler-Maclaurin summation formula.
