# Contour Integral of Gamma Functions from Knuth Paper

I was attempting to go through the addendum of Chapter 21 of Donald Knuth's Selected Papers on Analysis of Algorithms. In a lengthy derivation, Knuth asymptotically expands the following integral:

$$\frac{1}{2 \pi i} \int_{c-i \infty}^{c + i \infty } \frac{\Gamma(s-5/2)\Gamma(4-s) m^s \zeta(s)}{\Gamma(3/2)} ds \sim \frac{\Gamma(-3/2)\Gamma(3)}{\Gamma(3/2)} m + \sum_{n=0}^\infty \frac{(-1)^n}{n!} \frac{\Gamma(3/2+n)}{\Gamma(3/2)} m^{5/2-n} \zeta(5/2-n)$$

where $$\frac{5}{2} < c < 4$$. Knuth only states that the asymptotic series is obtained "by decreasing c as far as we like and adding up the residues of the poles of the integrand" - however I am having difficulty tracing the logic in how he did so.

Considering the more general integral

$$\frac{1}{2 \pi i} \int_{c-i \infty }^{c + i \infty } \frac{\Gamma(s-\alpha) \Gamma(\alpha+\beta-s)m^s\zeta(s)}{\Gamma(\beta)}$$

where $$\alpha = A+\frac{1}{2}, \beta = B-\frac{1}{2}$$ and both $$A,B \in \mathbb{N}$$. The domain of integration is taken as the limit of the line integral from $$c-iR$$ to $$c+iR$$ as $$R \to \infty$$.

Note first that the integrand has poles whenever $$s = k, k + \frac{1}{2}, k \in \mathbb{Z}$$. This function stems from an inverse Mellin transform with a fundamental strip of $$\{ z \in \mathbb{C} : \alpha < \Re(z) < \alpha + \beta \}$$, so the integrand is only defined on this strip but can be analytically continued to the whole complex plane.

Consider the contour $$C = L \cup S$$ where $$L$$ is the line segment going from $$s=c-iR$$ to $$s=c+iR$$ and $$S$$ be the semicircular contour going from $$s=c+iR$$ to $$s=c-iR$$ extending to the negative real axis (i.e. parametrized by $$S(t) = c + Re^{i \theta}$$ for $$\theta \in (\frac{\pi}{2}, \frac{3\pi}{2})$$). By the Residue Theorem, we have that $$\int_C f(z) dz = 2 \pi i \sum_{z \in [c, c-R] \cap \left( \mathbb{Z} \cup \mathbb{Z} + \frac{1}{2} \right)} \text{Res}\left(f; z\right)$$

where the sum is taken over the residues inside the contour (i.e. all integers and half integers in the interval $$[c, c-R]$$). We also have:

$$2 \pi i \sum \text{Res} f(z) = \int_C f(z) dz = \int_{c-iR}^{c+iR} f(z) dz + \int_S f(z) dz$$

If we have that $$\int_S f(z) dz \to 0$$ as $$R \to \infty$$, then Knuth's claim follows - however this is where I am stuck. I have tried to manipulate the inner gamma function terms with Stirling's approximation and have gotten nowhere, so some assistance here would be appreciated.

Note: I am aware that there are some theorems involving Mellin transforms that I think are mentioned in the original paper that Knuth cites - however, I am trying to avoid them as it is made to seem as though this is a straightforward computation. Any assistance would be appreciated!

Let $$f(s):=\frac{\Gamma(s-\alpha) \Gamma(\alpha+\beta-s)\zeta(s)}{\Gamma(\beta)},\ \ \ I:=\frac{1}{2\pi i}\int_{c-i\infty}^{c+i\infty} m^s f(s) \, ds.$$ You can derive an asymptotic series for $$I$$ if you integrate over the boundary of a rectangle which has a right edge at $$\hbox{Re } z=c$$, a left edge at $$\hbox{Re } z = K < 0$$, and top and bottom edges, $$\cal T$$ and $$\cal B$$, at $$\hbox{Im } z = \pm R$$. To do this, you can use the uniform bounds $$|\Gamma(x+iy)|\sim \sqrt{2 \pi}|y|^{x-(1/2)} \exp (-\pi |y|/2), \qquad \hbox{|y|\to\infty, x in any bounded interval,}$$ from [1] (derivable from Stirling's approximation. Added: To derive this, you can start with Stirling's approximation in the form $$\log \Gamma(z)=(z - \frac 12)\log z - z + \log \sqrt{2 \pi} + O(\frac{1}{|z|}), \qquad |z|\to\infty,$$ which is uniformly valid in $$\{z\mid |\arg z|\le \pi-\delta\}$$, for any fixed $$\delta>0$$.

Set $$z:=x+iy=x\pm i|y|$$, let $$x$$ be bounded and $$|y|\to\infty$$, and set $$r+i\theta:=\log z$$. Then, you get $$\begin{eqnarray*} r&=&\log \sqrt{x^2+y^2}=\log |y| + O(|y|^{-2}),\\ \theta&=&\pm \cos^{-1} \frac{x}{\sqrt{x^2+y^2}}\\ &=&\pm(\frac\pi 2 - \sin^{-1} \frac{x}{\sqrt{x^2+y^2}})\\ &=&\pm(\frac\pi 2 - \sin^{-1} \frac{x}{|y|(1+O(|y|^{-2}))})\\ &=&\pm(\frac\pi 2 - \frac{x}{|y|}+O(|y|^{-3})), \end{eqnarray*}$$ so $$\begin{eqnarray*} \log |\Gamma(z)|&=&\hbox{Re} \log \Gamma(z)\\ &=& (x - \frac 12)r-(\pm|y|)\theta-x +\log\sqrt{2\pi}+O(\frac{1}{|y|})\\ &=& (x - \frac 12)\log |y| - \frac{\pi}{2}|y|+\log\sqrt{2\pi}+o(1), \end{eqnarray*}$$ which is what you want), and, for any fixed right half-plane $$\{z\mid \hbox{Re } z \ge \sigma_0\}$$, $$\zeta(z)=O(|\hbox{Im } z|^A), \qquad \qquad \hbox{\hbox{Im } z\to\infty, for some A},$$ from [2]. If you fix $$K$$ and $$m$$, let $$R$$ become large, and apply these bounds to $$m^s f(s)$$ on $$\cal T$$ and $$\cal B$$, you can see that the integral of $$m^s f(s)$$ over $$\cal T$$ and $$\cal B$$ vanishes exponentially (it is $$O(R^B \exp(-\pi R))$$ for some $$B$$). This implies that $$I$$ equals the sum of the residues of the poles of $$m^s f(s)$$ inside the rectangle plus $$m^K J$$, where $$J:=\frac{1}{2\pi i} \int_{K-i\infty}^{K+i\infty} m^{i \ \small \rm Im\ \it s} f(s)\, ds.$$ If you pick $$K$$ so as to avoid the poles of $$f$$ and use the same bounds as for $$\cal T$$ and $$\cal B$$, this is enough to show that $$\int_{K-i\infty}^{K+i\infty} |f(s)|\, ds<\infty$$ so $$m^K J$$ is $$O(m^K)$$ as $$m\to\infty$$, giving the remainder term in the asymptotic series.

You should not expect to be able to push $$K$$ to $$-\infty$$ for a fixed $$m$$ since, using the reflection formulae ([3], [4]) $$\Gamma(s) = \frac{\pi}{\sin{(\pi s)} \Gamma(1-s)},\ \ \ \ \ \zeta(s)=\zeta(1-s) 2^s \pi^{s-1} \sin \left(\frac{\pi s}{2}\right) \Gamma(1-s)$$ you get $$m^s f(s)=\frac{m^s \Gamma(\alpha+\beta-s) \zeta(1-s) 2^s \pi^{s} \sin (\pi s/2) \Gamma(1-s)}{\sin(\pi(s-\alpha)) \Gamma(1+\alpha-s) \Gamma(\beta)}.$$ Using Stirling's approximation and $$\zeta(1-s)=\Theta(1)$$ for $$\hbox{Re }s \le -\epsilon$$, for any fixed $$\epsilon>0$$, you can then see that $$m^s f(s)$$ blows up as you let $$s$$ approach $$-\infty$$ along the negative real axis.

1: NIST Digital Library of Mathematical Functions, version 1.1.11, (5.11.9).

2: $$\S$$5.1, The Theory of the Riemann Zeta-Function, E. C. Titchmarsh, D. R. Heath-Brown, Oxford : Clarendon Press, 2nd ed., 1986.

3: NIST Digital Library of Mathematical Functions, version 1.1.11, (5.5.3).

4: NIST Digital Library of Mathematical Functions, version 1.1.11, (25.4.2).

• Thanks! I think the main thing I was struggling with was the bounds on the gamma function - out of curiosity how would you derive that from just Stirling's formula? Oct 12, 2023 at 5:54
• I added this to the answer. Oct 13, 2023 at 15:32