I'm trying to evaluate the following integral, but I think I don't do something correctly. I'm interested where my try failed, compared to other ways.
$ \int_{-\infty}^\infty\frac{\cos x}{1+x^2}\;dx\ $
I tried in 2 ways:
I defined $\gamma = \gamma_1 + \gamma_2 $, where $ \gamma_1 = [-R, R], \gamma_2 = R e^{it}, t \in [0, \pi] $, and letting R aproach infinity. So the integral on $\gamma_2$ approaches zero, and by residue theorem, we see that $ \int_{-\infty}^\infty\int_{\gamma} f(z)dz = 2\pi i Res(f, i) = 2\pi i \frac{cosz}{z+i} $.
Letting $ z=i$ does not give me the correct result, since $ \cos i = \frac{e + \frac{1}{e}}{2} $
The second way: by partial decomposition, I see that $$ \int_{-\infty}^\infty\frac{\cos z}{1+z^2}\;dx\ = \int_{-\infty}^\infty\frac{i\cos z}{2(z+i)}\;dx\ + \int_{-\infty}^\infty\frac{-i\cos z}{2(z-i)}\;dx\ $$ and by Cauchy's theorem for integrals, the first integral is zero, and the latter is $ \pi i (-i) \cos i $, which is still not the correct result..
What do I miss here?