<s>[INST] Evaluating the integral $ \int_{-\infty}^{\infty} \frac{\cos \left(x-\frac{1}{x} \right)}{1+x^{2}} \ dx$ 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?
 [/INST] Let $x-1/x = t$. Now note that $t^2 = x^2 + \dfrac1{x^2} -2 \implies \left(x+\dfrac1x \right)^2 = t^2+4$. We then get that
$$\left(1 + \dfrac1{x^2} \right)dx = dt \implies \dfrac{dx}{1+x^2} = \dfrac{x^2}{(1+x^2)^2} dt = \dfrac{dt}{\left(x+1/x \right)^2} = \dfrac{dt}{t^2+4}$$
Hence, the integral becomes
$$\int_{-\infty}^{\infty} \dfrac{\cos(x-1/x)}{x^2+1} dx = 2 \int_{0}^{\infty} \dfrac{\cos(x-1/x)}{x^2+1} dx = 2\int_{-\infty}^{\infty} \dfrac{\cos(t)}{t^2+4} dt = \dfrac{\pi}{e^2}$$
where the last integral can be obtained from the post below.
Calculating the integral $\int_{0}^{\infty} \frac{\cos x}{1+x^2}\mathrm{d}x$ without using complex analysis
</s>