Calculating $\int_{0}^{\infty} x^{a-1} \cos(x) \ \mathrm dx = \Gamma(a) \cos (\pi a/2)$

Consider the contour integral

$$\oint_C dz \, z^{a-1} \, e^{i z}$$

where $C$ is a quarter circle of radius $R$ in the 1st quadrant (real and imaginary $> 0$), with a small quarter circle of radius $\epsilon$ about the origin cut out (to avoid the branch point at the origin).

This integral is equal to

$$\int_{\epsilon}^R dx \, x^{a-1} \, e^{i x} + i R^a \int_0^{\pi/2} d\theta \, e^{i a \theta} e^{i R \cos{\theta}} \, e^{-R \sin{\theta}}\\+ i \int_R^{\epsilon} dy \, e^{i \pi (a-1)/2} y^{a-1} e^{-y} + i \epsilon^a \int_{\pi/2}^0 d\phi \, e^{i a \phi} \, e^{i \epsilon e^{i \phi}}$$

We note that the second integral vanishes as $R\to\infty$ because $\sin{\theta} \gt 2 \theta/\pi$, so that the magnitude of that integral is bounded by

$$R^a \int_0^{\pi/2} d\theta \, e^{-R \sin{\theta}} \le R^a \int_0^{\pi/2} d\theta \, e^{-2 R \theta/\pi} \le \frac{2}{\pi R^{1-a}}$$

We also note that the fourth integral vanishes as $\epsilon^a$ as $\epsilon \to 0$. In the third integral, we write $i=e^{i \pi/2}$ to make a simplification.

The contour integral is zero by Cauchy's Theorem (no poles in the interior of $C$). Ths we have (+)

$$\int_{0}^{\infty} dx \, x^{a-1} \, e^{i x} - e^{i \pi a/2} \int_0^{\infty} dy \, y^{a-1} \, e^{-y}=0$$

We use the definition of the gamma function:

$$\Gamma(a) = \int_0^{\infty} dy \, y^{a-1} \, e^{-y}$$

and take real parts of (+) to obtain the sought-after result.


$\newcommand{\+}{^{\dagger}}% \newcommand{\angles}[1]{\left\langle #1 \right\rangle}% \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}% \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}% \newcommand{\ceil}[1]{\,\left\lceil #1 \right\rceil\,}% \newcommand{\dd}{{\rm d}}% \newcommand{\ds}[1]{\displaystyle{#1}}% \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}% \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}% \newcommand{\fermi}{\,{\rm f}}% \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}% \newcommand{\half}{{1 \over 2}}% \newcommand{\ic}{{\rm i}}% \newcommand{\imp}{\Longrightarrow}% \newcommand{\isdiv}{\,\left.\right\vert\,}% \newcommand{\ket}[1]{\left\vert #1\right\rangle}% \newcommand{\ol}[1]{\overline{#1}}% \newcommand{\pars}[1]{\left( #1 \right)}% \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}}% \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}% \newcommand{\sech}{\,{\rm sech}}% \newcommand{\sgn}{\,{\rm sgn}}% \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}}% \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}% \newcommand{\yy}{\Longleftrightarrow}$ $\ds{\bbox[5px,#ffd]{\int_{0}^{\infty} x^{a - 1}\cos\pars{x}\,\dd x = \Gamma\pars{a}\cos\pars{\pi a \over 2}}:\ {\large ?}}$.


Note that $\ds{\int_{0}^{\infty}x^{a - 1} \cos\pars{x}\,\dd x = \Re\int_{0}^{\infty}x^{a - 1}\expo{\ic x}\,\dd x}$.
With the change of variable $x \equiv \expo{\ic\pi/2}\,t$, we'll have: \begin{align} &\int_{0}^{\infty}x^{a - 1}\cos\pars{x}\,\dd x = \Re\int_{0}^{-\ic\infty}\pars{\expo{\ic\pi/2}t}^{a - 1} \expo{-t}\,\ic\,\dd x \\[3mm] = &\ \Re\bracks{\expo{\ic\pi a/2} \int_{0}^{-\ic\infty}t^{a - 1} \expo{-t}\,\dd x} \\[3mm] = &\ \Re\braces{\expo{\ic\pi a/2}\bracks{-\int_{\infty}^{0}t^{a - 1}\expo{-t}\,\dd x}} \\[3mm] = &\ \Re\bracks{\expo{\ic\pi a/2}\ \overbrace{\int_{0}^{\infty}t^{a - 1}\expo{-t}\,\dd x\ }^{\ds{=\ \Gamma\pars{a}}}} \\[5mm] = &\ \underbrace{\ \Re\bracks{\expo{\ic\pi a/2}}\ } _{\ds{=\ \cos\pars{\pi a/2}}} \Gamma\pars{a} \end{align}
\begin{align} &\mbox{} \\ &\bbox[10px,border:1px groove navy]{% \int_{0}^{\infty}x^{a - 1}\cos\pars{x}\,\dd x = \Gamma\pars{a}\cos\pars{\pi a \over 2}} \\ & \end{align}

I recently read a short, yet interesting, article by Boas and Friedman where the authors calculated this same integral by using a different kind of contour:

a triangle with vertices $-p_{1}, \;\ p_{2}, \;\ (p_{1}+p_{2})i$.

Consider $R(z)e^{iz}$, where R(z) is a rational function that vanishes at $\infty$

Then, $p_{1}, \;\ p_{2}$ are taken to be sufficiently large as to enclose the poles in the UHP.

Instead of using the arc of a circle in the first quadrant, they use a straight line segment.

By letting $p_{1}, \;\ p_{2} \to \infty$ the integral over the real axis is equal to $2\pi i$ times the sum of the residues in the UHP.

This computation is claimed to be simpler because the slope of the triangular contour is bounded away from 0 in the UHP.

Connect the points $z=p, \;\ z=pi$ with a line rather than the arc of a circle.

On this line, $|dz|=\sqrt{2}dy$ and $\frac{1}{|z|}\leq \frac{\sqrt{2}}{p}$.

It follows immediately that the integral over the line is bounded by a constant times

$p^{s-1}\int_{0}^{p}e^{-y}dy\leq p^{s-1}$ which tends to 0 as $p\to \infty$ since $s<1$.

I have not included all of the intricacies, so if any one is interested in looking over this article it is in JSTOR. Look for "a simplification in certain contour integrals".