I am a bit puzzled by the expression $\displaystyle I=\int_{-\infty}^\infty\frac{\cos x}{1+x^2}\,dx$.
If I try solving it using Cauchy's formula, I arrive to $I=2\pi i \frac{\cos i}{2i} = \pi\cos i$.
EDIT: In detail, I am trying the common trick of calculating the integral over a semi-circumference of radii $r$ and the line from $-r$ to $r$. Since the integral over the semi-circunference goes to zero as r goes to infinity, I can use that to calculate the integral over the real line.
But the result I expected is $\frac{\pi}{e}$, since that is what i get if I first substitute $\cos x$ by $e^{ix}$ in the expression, which should be a legal move since $e^{ix}= \cos x + i \sin x$ and $\sin x$ is an odd function, so its integral from $-\infty$ to $\infty$ is $0$.
What is going on?