TITLE: Evaluating the integral $ \int_{-\infty}^{\infty} \frac{\cos \left(x-\frac{1}{x} \right)}{1+x^{2}} \ dx$
QUESTION [14 upvotes]: I'm curious about the proper way to evaluate $$ \int_{-\infty}^{\infty} \frac{\cos \left(x-\frac{1}{x} \right)}{1+x^{2}} \, dx =  \text{Re} \int_{-\infty}^{\infty} \frac{e^{i(x- \frac{1}{x})}}{1+x^{2}} \, dx$$ using contour integration.
If I let $f(z) = \frac{e^{i(z- \frac{1}{z})}}{1+z^{2}}$, there is an essential singularity at the origin.
So if I integrate around a closed semicircle in the upper half-plane, the contour goes right through the singularity.
Can you indent a contour around an essential singularity?

REPLY [2 votes]: You're right that the residue calculation is sufficient. Note that
$$\left|\int_0^\pi \frac{e^{i(z-z^{-1})}}{1+z^2} \times ir e^{i\theta}\mathrm{d}\theta\right|$$
is bounded by 
$$r\left|\int_0^\pi e^{-\frac{1}{r} \times \sin\theta}\mathrm{d}\theta\right| < r\pi \to 0$$
Hence indenting the contour around the origin makes for no difference between the real integral and the complex one. Then note the integrand is meromorphic within the region with this boundary. The behaviour outside of this contour is irrelevant, essential singularities or otherwise.
Thus the residue at $i$, $\boxed{\pi/e^2}$, is the correct value.
The argument does not work for e.g. a contour passing through the origin since the function is non-analytic at the origin, so Cauchy's theorem does not apply.