I'm trying to find the integral

$$\int_{-\infty}^{\infty}\frac{\cos x}{a^2+x^2}dx$$

Wolfram alpha says this is $$\frac{\pi e^{-a}}{a}$$ But how do you get this result? I tried using partial integration and some substitutions but I'm not getting there...


Let $f(z) = \frac{1}{a^2 + z^2}$, then $f(z)e^{iz}$ is analytic everywhere execept at $z = ia$. Take $R > a$ and $C_R$ the upper half circle $|z| = R$.

$$\int_{-R}^{R} \frac{\cos x}{a^2+x^2} dx = 2\pi i\ Res_{z=ia}[f(z)e^{iz}] - Re\int_{C_R}f(z)e^{iz} dz$$

Now $$f(z) = \frac{\phi (z)}{z-ia} \ \ \text{where} \ \ \phi(z) =\frac{e^{iz}}{z + ia}$$

Then $$Res_{z=ia}[f(z)e^{iz}] = \phi (ia) = \frac{e^{-a}}{2ia}$$

And $|f(z)| \leq M_R$ where $M_R = \frac{1}{(R^2 - a^2)}$

$$\begin{align}\Bigg|Re\int_{C_R}f(z)e^{iz} dz\Bigg|&\leq \Bigg|\int_{C_R}f(z)e^{iz} dz\Bigg|\\&\leq\int_{C_R}|f(z)||e^{iz}|dz \leq \frac{\pi R}{(R^2-a^2)} \to 0\end{align}$$

when $R \to \infty$. Thus we may conclude that

$$\int_{-\infty}^{\infty} \frac{\cos x}{a^2+x^2} dx = 2\pi i\ \frac{e^{-a}}{2ia} -0 = \frac{\pi e^{-a}}{a}$$