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?
Using the symmetry: $$ \int_{\mathbb{R}} \frac{\cos\left(x-\frac{1}{x}\right)}{1+x^2} \mathrm{d}x = 2 \int_0^\infty \frac{\cos\left(x-\frac{1}{x}\right)}{1+x^2} \mathrm{d}x $$ Now, making the change of variables $u = x-\frac{1}{x}$ there are two solutions: $$ x = x_{\pm}(u) = \frac{u}{2} \pm \sqrt{1 + \frac{u^2}{4}} $$ Changing variables: $$ 2 \int_0^\infty \frac{\cos\left(x-\frac{1}{x}\right)}{1+x^2} \mathrm{d}x = \int_{-\infty}^\infty \frac{2 \cos(u)}{1+x_+(u)^2} \frac{x_+^\prime(u)}{2} \mathrm{d}u + \int_{-\infty}^\infty \frac{2 \cos(u)}{1+x_-(u)^2} \frac{x_-^\prime(u)}{2} \mathrm{d}u $$ Combining these, with some simple algebra: $$\begin{eqnarray} 2 \int_0^\infty \frac{\cos\left(x-\frac{1}{x}\right)}{1+x^2} \mathrm{d}x &=& \int_{-\infty}^\infty \frac{2 \cos(u)}{4+u^2} \mathrm{d}u = \\ &=& \Re \int_{-\infty}^\infty \frac{2 \mathrm{e}^{i u}}{4+u^2} \mathrm{d}u = \Re\left( 2 \pi i \operatorname{Res}_{u=2i} \frac{2 \mathrm{e}^{i u}}{4+u^2}\right) = \frac{\pi}{\mathrm{e}^2} \end{eqnarray} $$ Note, that the above substitution is related to the Cauchy-Schlömilch substitution (see arXiv:1004.2445).
Numerical check: