Asymptotic Expansion of Digamma Function While reading the wikipedia page of the Digamma function (https://en.wikipedia.org/wiki/Digamma_function#Asymptotic_expansion)
I noticed that it said the asymptotic expansion for the digamma function ($\psi(z)$) can be obtained from using
\begin{equation} \psi(z+1) = -\gamma + \sum_{n=1}^{\infty} (\frac{1}{n} - \frac{1}{n+z}) \end{equation} (where $\gamma$ is the Euler–Mascheroni constant) combined with Euler–Maclaurin formula to conclude
\begin{equation} \psi(z) \approx \log(z) - \frac{1}{2z} \end{equation}   My main confusion about this is that when I tried to use the Euler–Maclaurin formula to approximate the sum as an integral, I could not figure out how to obtain a $\gamma$ to cancel out the $\gamma$ term in the series expansion. Any  help on how to obtain the above relationship using the formula or just where the $\gamma$ comes from when I apply the Euler-Maclaurian formula would be greatly appreciated!
 A: I shall assume that $|\arg (z+1)|<\pi$. By the Euler–Maclaurin formula,
\begin{align*}
\psi (z + 1) = &  - \gamma  + \int_1^{ + \infty } {\left( {\frac{1}{t} - \frac{1}{{t + z}}} \right)dt}  + \frac{1}{2}\left( {1 - \frac{1}{{1 + z}}} \right) \\ & + \int_1^{ + \infty } {\left( {\left\{ {1 - t} \right\} - \frac{1}{2}} \right)\left( {\frac{1}{{t^2 }} - \frac{1}{{(t + z)^2 }}} \right)dt} 
\\  = & \; \log (z + 1) - \gamma  + \int_1^{ + \infty } {\frac{{\left\{ {1 - t} \right\}}}{{t^2 }}dt}  - \frac{1}{{2(z + 1)}} - \int_1^{ + \infty } {\frac{{\left\{ {1 - t} \right\} - \frac{1}{2}}}{{(t + z)^2 }}dt}.
\end{align*}
Thus, it remains to show that
$$
\int_1^{ + \infty } {\frac{{\left\{ {1 - t} \right\}}}{{t^2 }}dt}  = \gamma 
$$
and
$$
\int_1^{ + \infty } {\frac{{\left\{ {1 - t} \right\} - \frac{1}{2}}}{{(t + z)^2 }}dt}  = \mathcal{O}\!\left( {\frac{1}{{(z + 1)^2 }}} \right).
$$
The first one can be shown as follows:
\begin{align*}
\int_1^{ + \infty } {\frac{{\left\{ {1 - t} \right\}}}{{t^2 }}dt} & =\sum\limits_{k = 1}^\infty  {\int_k^{k + 1} {\frac{{\left\{ {1 - t} \right\}}}{{t^2 }}dt} }  = \sum\limits_{k = 1}^\infty  {\int_0^1 {\frac{{1 - t}}{{(k + t)^2 }}dt} } \\ & = \sum\limits_{k = 1}^\infty  {\left[ {\frac{1}{k} - \log \left( {1 + \frac{1}{k}} \right)} \right]}  = \mathop {\lim }\limits_{n \to  + \infty } \sum\limits_{k = 1}^n {\left[ {\frac{1}{k} - \log \left( {1 + \frac{1}{k}} \right)} \right]} 
\\ &
 = \mathop {\lim }\limits_{n \to  + \infty } \left(\sum\limits_{k = 1}^n {\frac{1}{k}}  - \log (n + 1) \right)= \gamma .
\end{align*}
For the second claim, we use integration by parts and some estimations to obtain
\begin{align*}
& \left| {\int_1^{ + \infty } {\frac{{\left\{ {1 - t} \right\} - \frac{1}{2}}}{{(t + z)^2 }}dt} } \right| = \left| {\int_1^{ + \infty } {\frac{{\left\{ t \right\} - \left\{ t \right\}^2 }}{{(t + z)^3 }}dt} } \right| \\ & \le \frac{1}{4}\int_1^{ + \infty } {\frac{1}{{\left| {t + z} \right|^3 }}dt}  = \frac{1}{4}\int_0^{ + \infty } {\frac{1}{{\left| {t + (z + 1)} \right|^3 }}dt} 
\\ &
 \le \frac{1}{4}\int_0^{ + \infty } {\frac{1}{{(t + \left| {z + 1} \right|)^3 }}dt} \sec ^3 \left( {\frac{{\arg (z + 1)}}{2}} \right) = \frac{1}{{8\left| {z + 1} \right|^2 }}\sec ^3 \left( {\frac{{\arg (z + 1)}}{2}} \right).
\end{align*}
In summary, replacing $z+1$ by $z$,
$$
\psi (z) = \log z - \frac{1}{{2z}} + R(z)
$$
where
$$
\left| {R(z)} \right| \le \frac{1}{{8\left| z \right|^2 }}\sec ^3 \left( {\frac{{\arg z}}{2}} \right)
$$
and $|\arg z|<\pi$. With more careful considerations, the constant $\frac{1}{8}$ can be replaced by $\frac{1}{12}$.
A: The harmonic number $H_{n}$ is defined as
\begin{equation*}
H_n=1+\frac12+\frac13+\cdots+\frac1n, \quad n\in\mathbb{N}
\end{equation*}
and satisfies
\begin{equation*}%\label{def-gamma}
\gamma=\lim_{n\to\infty}(H_n-\ln n)=0.57721\dotsc
\end{equation*}
and
\begin{equation*}\label{H-gamma}
H_n=\psi(n+1)+\gamma,
\end{equation*}
where $\gamma$ is the Euler–-Mascheroni constant and $\psi(x)$ is the digamma function which is the logarithmic derivative of the classical Euler gamma function
\begin{equation*}%\label{gamma-dfn}
\Gamma(z)=\int_0^\infty t^{z-1}\textrm{e}^{-t}\textrm{d}\,t, \quad \Re(z)>0.
\end{equation*}
Is the Euler–-Mascheroni constant $\gamma$ irrational? This is a famous but unsolved problem. See https://mathworld.wolfram.com/Euler-MascheroniConstant.html.
On page 257 and page 260 in the handbook [1] below, the formulas 6.1.40 and 6.4.11 read that
\begin{align}\label{ln-gamma-symp-eq}
\ln\Gamma(w)&\sim\biggl(w-\frac12\biggr)\ln w-w+\frac12\ln(2\pi)+\sum_{k=1}^\infty \frac{B_{2k}}{2k(2k-1)w^{2k-1}},\\
\psi(w)&\sim\ln w-\frac{1}{2w}-\sum_{k=1}^\infty \frac{B_{2k}}{2kw^{2k}},\label{ln-psi-symp-eq}
\end{align}
and
\begin{equation}\label{asymptotic-polypsi}
\psi^{(n)}(w)\sim(-1)^{n-1}\biggl[\frac{(n-1)!}{w^n}+\frac{n!}{2w^{n+1}}+\sum_{k=1}^\infty B_{2k}\frac{(2k+n-1)!}{(2k)!w^{2k+n}}\biggr]
\end{equation}
as $w\to\infty$ in $\lvert \arg w\rvert<\pi$ for $n\in\mathbb{N}$, where $B_{2k}$ for $k\ge1$ are known as the Bernoulli numbers which can be generated by
\begin{equation*}%\label{Bernoulli-numbers-dfn}
\frac{w}{e^w-1}=1-\frac{w}2+\sum_{k=1}^\infty B_{2k}\frac{w^{2k}}{(2k)!}, \quad| w| <2\pi.
\end{equation*}
See https://math.stackexchange.com/a/4254493/945479, https://math.stackexchange.com/a/4256893/945479, and https://math.stackexchange.com/a/4248341/945479.
References

*

*M. Abramowitz and I. A. Stegun (Eds), Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, National Bureau of Standards, Applied Mathematics Series 55, Reprint of the 1972 edition, Dover Publications, Inc., New York, 1992.

*Bai-Ni Guo and Feng Qi, Sharp inequalities for the psi function and harmonic numbers, Analysis---International mathematical journal of analysis and its applications 34 (2014), no. 2, 201--208; available online at https://doi.org/10.1515/anly-2014-0001.

*Da-Wei Niu, Yue-Jin Zhang, and Feng Qi, A double inequality for the harmonic number in terms of the hyperbolic cosine, Turkish Journal of Analysis and Number Theory 2 (2014), no. 6, 223--225; available online at https://doi.org/10.12691/tjant-2-6-6.

*N. M. Temme, Special Functions: An Introduction to Classical Functions of Mathematical Physics, A Wiley-Interscience Publication, John Wiley & Sons, Inc., New York, 1996; available online at http://dx.doi.org/10.1002/9781118032572.

