Why I can not calculate the residual of $\frac{\cos(x)}{x^2+1}$ like this to solve this integral?

55 Views Asked by At

I have the following integral to solve: $$I =\int_{-\infty}^{+\infty}\frac{\cos(x)}{x^2+1}$$ and after applying the big circle lemma and the residue theorem, I run into this expression: $$I = \pi i \cdot Res\left(\frac{\cos(z)}{z^2+1}\right)_{z=i}$$ So i calculate the residue as follows: $$I = \pi iRes\left(\frac{\cos(z)}{z^2+1}\right)_{z=i} = \pi i\left.\frac{\cos(z)}{2z}\right\vert_{z=i} = \pi i \frac{\cos(i)}{2i} = \frac{\pi}{2}\frac{e^{i^2}+e^{-i^2}}{2} = \frac{\pi}{4}\left(\frac{1}{e}+e\right)$$ However, the solution should be $\frac{\pi}{e}$ (checked also with Wolfram Alpha). The book solves it by writing $\cos(z)$ as $\mathfrak{Re}(e^{iz})$ (the real part of $e^{iz}$) and then calculating the redisue of $\frac{e^{iz}}{z^2+1}$ and making the cosine re-appear in place of $e^{iz}$ in the end. Why is this the correct way? Why is it wrong to do like I did?