Complex integral of $\frac{\cos x}{x^2+4} $ I want to evaluate:
$$ \int_{-\infty}^{\infty}\frac{\cos x}{x^2 +4} dx $$
Using wolfram alpha, it gave an answer of $\frac{\pi}{2e^2}$. Wolfram Alpha is never wrong.
Attempt
$$ \int_{-\infty}^{\infty}\frac{\cos z}{z^2 +4} dx = \frac{1}{2} \frac{e^{-iz} + e^{iz}}{(z+2i)(z-2i)} $$
Residue at $z=2i$ is $ \frac{\cosh 2}{4i} $
Taking this particular contour:

Expanding radius to infinity, by Jordan's Lemma $\int_\gamma \rightarrow 0$ and we are left with:
$$ \int_{-\infty}^{\infty} \frac{e^{-ix} + e^{iz}}{(x+2i)(x-2i)} dx = 2\pi i \times \frac{\cosh 2}{4i} $$
$$  \int_{-\infty}^{\infty}\frac{\cos x}{x^2 +4} dx  = \frac{\pi}{4} \cosh (2) $$ 
 A: Since $e^{-iz}$ is unbounded on the upper half-plane, Jordan's lemma does not apply. And the integral over the semicircle does not tend to $0$ when the radius tends to $\infty$, as can be seen from the differing results.
You can either split the integrand, and compute the integral of $\dfrac{e^{iz}}{z^2+4}$ over the contour in the upper half-plane - $e^{iz}$ behaves nicely on the upper half plane, since $\lvert e^{iz}\rvert = e^{-\operatorname{Im} z} \to 0$ for $\operatorname{Im} z \to +\infty$ - and the integral of $\dfrac{e^{-iz}}{z^2+4}$ over the analogous contour in the lower half-plane (where $e^{-iz}$ behaves nicely), or simply note that $\cos x = \operatorname{Re} e^{ix}$ for real $x$, and use only $\dfrac{e^{iz}}{z^2+4}$. Then Jordan's lemma applies. By parity, the imaginary part of $\int\limits_{-\infty}^\infty \dfrac{e^{ix}}{x^2+4}\,dx$ vanishes, so
$$\int_{-\infty}^\infty \frac{\cos x}{x^2+4}\,dx = \int_{-\infty}^\infty \frac{e^{ix}}{x^2+4}\,dx = 2\pi i \operatorname{Res} \left(\frac{e^{iz}}{z^2+4};2i\right) = 2\pi i \frac{e^{-2}}{4i} = \frac{\pi}{2e^2}.$$
