# Computing $\int_{-\infty}^{\infty} \frac{\cos x}{x^{2} + a^{2}}dx$ using residue calculus

I need to find $\displaystyle\int_{-\infty}^{\infty} \frac{\cos x}{x^{2} + a^{2}}\ dx$ where $a > 0$. To do this, I set $f(z) = \displaystyle\frac{\cos z}{z^{2} + a^{2}}$ and integrate along the semi-circle of radius $R$. For the residue at $ia$ I get $\displaystyle\frac{\cos(ia)}{2ia}$. Then letting $R \rightarrow \infty$, the integral over the arc is zero, so I get $\displaystyle\int_{-\infty}^{\infty} \frac{\cos x}{x^{2} + a^{2}}\ dx = 2 \pi i \frac{\cos(ia)}{2ia} = \frac{\pi \cos(ia)}{a}$. But this is supposed to be $\displaystyle\frac{\pi e^{-a}}{a}$, so I am doing something wrong.

In a similar problem, I have to evaluate $\displaystyle\int_{-\infty}^{\infty} \frac{x \sin x}{x^{2} + a^{2}}\ dx$ and get $\pi i \sin(ia)$ whereas this is supposed to be $\pi e^{-a}$. I think I am getting some detail wrong in both cases. Can anyone enlighten me?

-
The integral over the arc is NOT zero if you are integrating $\cos(x)$ (cosines become hyperbolic cosines for imaginary $x$ which grow exponentially!). It IS, if you replace $\cos x$ with $e^{ix}$ and then take the real part at the very end of the evaluation. – Alex R. May 3 '12 at 20:51
I was able to derive the result correctly by replacing $\cos(x)$ with $e^{ix}$ as you said, but I do not understand why the integral would not be zero. The length of the curve is $\pi R$. The supremum would be at most $\frac{1}{R^{2} + a^{2}}$. How come this isn't zero? – Pedro May 3 '12 at 21:03
Again, you are thinking that $\cos(x)$ is between -1 and 1, but this is only true for real $x$. Otherwise you have $\cos(x)=\frac{e^{ix}+e^{-ix}}{2}$ so try to plug in $x=a+bi$ and you will see that you are gurunteed to have exponential blowup as $|x|\rightarrow \infty$ along any path away from the real axis – Alex R. May 3 '12 at 21:52
You really need either to use $\cos(x)=\frac{\exp(ix)+\exp(-ix)}{2}$ or $\cos(x)=\Re(\exp(ix))$ so that we work with $\exp(ix)$ over the upper half-plane. $\cos(ix)$ blows up exponentially as the imaginary part of $x$ gets large, so we can't use it in the contour integration. – robjohn May 4 '12 at 2:23

Let $\gamma$ be the path along the real axis then circling back counter-clockwise through the upper half-plane, letting the circle get infinitely big. \begin{align} \int_{-\infty}^\infty\frac{\cos(x)}{x^2+a^2}\mathrm{d}x\tag{1} &=\Re\left(\int_{-\infty}^\infty\frac{\exp(ix)}{x^2+a^2}\mathrm{d}x\right)\\\tag{2} &=\Re\left(\int_{\gamma}\frac{\exp(ix)}{x^2+a^2}\mathrm{d}x\right)\\\tag{3} &=\Re\left(2\pi i\,\mathrm{Res}\left(\frac{\exp(ix)}{x^2+a^2},ia\right)\right)\\\tag{4} &=\Re\left(2\pi i\,\lim_{z\to ia}\frac{\exp(ix)}{x+ia}\right)\\\tag{5} &=\Re\left(2\pi i\,\frac{\exp(-a)}{2ia}\right)\\ &=\frac{\pi \exp(-a)}{a} \end{align} $(1)$: $\Re(\exp(ix))=\cos(x)$

$(2)$: The integral along the circle back through the upper half-plane vanishes as the circle gets bigger.

$(3)$: There is only one singularity of $\dfrac{\exp(ix)}{x^2+a^2}$ in the upper half-plane, at $x=ia$. The integral along $\gamma$ is the residue of $\dfrac{\exp(ix)}{x^2+a^2}$ at $x=ia$.

$(4)$: The singularity of $\dfrac{\exp(ix)}{x^2+a^2}$ at $x=ia$ is a simple pole. We can compute the residue as $\displaystyle\lim_{x\to ia}(x-ia)\frac{\exp(ix)}{x^2+a^2}=\lim_{x\to ia}\frac{\exp(ix)}{x+ia}$.

$(5)$: plug in $x=ia$.

Following the same strategy, \begin{align} \int_{-\infty}^\infty\frac{x\sin(x)}{x^2+a^2}\mathrm{d}x &=\Im\left(\int_{-\infty}^\infty\frac{x\exp(ix)}{x^2+a^2}\mathrm{d}x\right)\\ &=\Im\left(\int_{\gamma}\frac{x\exp(ix)}{x^2+a^2}\mathrm{d}x\right)\\ &=\Im\left(2\pi i\,\mathrm{Res}\left(\frac{x\exp(ix)}{x^2+a^2},ia\right)\right)\\ &=\Im\left(2\pi i\,\lim_{z\to ia}\frac{x\exp(ix)}{x+ia}\right)\\ &=\Im\left(2\pi i\,\frac{ia\exp(-a)}{2ia}\right)\\ &=\pi \exp(-a) \end{align}

-

Let us integrate along the contour $\Gamma$, which is the semicircle of radius $R$ described above. Let $C_R$ be the arc of the contour with radius $R$. We may say that

$$\oint_{\Gamma}\frac{\cos z}{z^2+a^2}\, dz=\int_{-R}^{R}\frac{\cos x}{x^2+a^2}\, dx+\int_{C_R}\frac{\cos z}{z^2+a^2}\, dz$$

Note that $\cos x = \operatorname{Re}\,(e^{ix})$. Thus

$$f(z)=\frac{\operatorname{Re}\,(e^{iz})}{z^2+a^2} = \operatorname{Re}\,\left(\frac{e^{iz}}{(z+ia)(z-ia)}\right)$$

Because $f(z)$ can be written ias $g(z)e^{iaz}$ and suffices all of the conditions of Jordan's lemma, we see that the integral along the arc tends to zero when $R\to \infty$. Thus

$$\lim_{R\to\infty}\oint_{\Gamma}\frac{\cos z}{z^2+a^2}\, dz=\lim_{R\to\infty} \int_{-R}^{R}\frac{\cos x}{x^2+a^2}\, dx+0$$

To solve the LHS, we find the residues. The residue, similar to the one you found is $$b=\frac{e^{i^2a}}{ia+ia}=\frac{e^{-a}}{2ia}$$

Thus

$$\displaystyle\int_{-\infty}^{\infty} \frac{\cos x}{x^{2} + a^{2}}\, dx= \lim_{R\to\infty}\oint_{\Gamma}\frac{\cos z}{z^2+a^2}\, dz=\operatorname{Re}\,\left(\displaystyle\int_{-\infty}^{\infty} \frac{e^{iz}}{z^{2} + a^{2}}\, dz\right) =\operatorname{Re}\,(2\pi ib)=\operatorname{Re}\,(2\pi i\frac{e^{-a}}{2ia}) = \frac{\pi e^{-a}}{a}$$

Similarly, with $\displaystyle\int_{-\infty}^{\infty} \frac{x \sin x}{x^{2} + a^{2}}\ dx$ we change $\sin x$ to $\operatorname{Im}\,(e^{ix})$ and make the function complex-valued.

$$g(z)=\frac{z\sin z}{z^2+a^2}=\operatorname{Im}\,\left(\frac{ze^{iz}}{(z+ia)(z-ia)}\right)$$

Jordan's lemma again can be used to show that the integral around the arc tends to zero as $R\to\infty$. We then proceed to find the residues. The residue of pole $z_1=ia$ is

$$b=\frac{iae^{-a}}{2ia}=\frac{e^{-a}}{2}$$

$z_1$ is the unique pole in the contour, so upon multiplying its residue, $b$, with $2\pi i$ we find: $$\displaystyle\int_{-\infty}^{\infty} \frac{x \sin x}{x^{2} + a^{2}}\, dx= \lim_{R\to\infty}\oint_{\Gamma} \frac{x \sin x}{x^{2} + a^{2}}\, dz= \operatorname{Im}\,\left(\displaystyle\int_{-\infty}^{\infty} \frac{ze^{iz}}{(z+ia)(z-ia)}\, dz\right)= \operatorname{Im}\,(2\pi ib)= \operatorname{Im}\,(2\pi i \frac{e^{-a}}{2})= \operatorname{Im}\,(\pi e^{-a}i)= \pi e^{-a}$$

-
It would be good to describe the contour along which you are integrating. – robjohn May 4 '12 at 0:34
@robjohn I am using the one described above: "integrate along the semi-circle of radius R"... – Argon May 4 '12 at 1:09
@Argon Maybe also mention one needs to use Jordan's lemma to estimate the contribution from the arc for the $\int \frac{x\sin x}{x^2+a^2} dx$ integral, just the usual Length * Max estimate fails there. – Ragib Zaman May 4 '12 at 1:19
@RagibZaman Very true, I will include this. – Argon May 4 '12 at 1:49
@robjohn the contour he uses is clearly stated the first sentence, re-read the solution. Very nice solution Argon, thanks a lot! – Integrals Dec 17 '13 at 5:59