I tried to calculate the integral $$I=\int_{-\infty }^{\infty } \frac{\cos x}{x^2+1} \, dx$$ using residues and got $$I=2\pi i \text{ Res}\left(\frac{\cos x}{x^2+1},(x,i)\right)=\pi \cosh 1\approx 4.8$$ which is nonsense because the graph of $y=\frac{\cos x}{x^2+1}$ is between $-\frac{1}{x^2+1}$ and $\frac{1}{x^2+1}$, the area between these two curves is $2\pi$ and $I\approx 4.8$ is too much.
Mathematica gives $I=\frac{\pi}{e}\approx 1.15573$ which makes much more sense.
My questions are.
- Given that my use of residue is wrong, what does $\pi \cosh 1$ represent?
- Why residue is wrong in this example?