Different solution for same contour integral $\int_{0}^{\infty}\frac{\cos(x)}{1+x^2}dx$ This question might be silly but I am quite puzzled by this problem.
In this exercise I am required to solve the following integral
$$\int_{0}^{\infty}\frac{\cos(x)}{1+x^2}dx$$
which I will call $A$ from now on. Since $f(x)= f(-x)$ I conclude $$A = \frac{1}{2} \int_{-\infty}^{\infty}\frac{\cos(x)}{1+x^2}dx.$$
Now I can switch to the complex variable $z$ and rewrite  $\cos(z)$ as $\frac{e^{iz}+e^{-iz}}{2}$ and obtain
$$\frac{1}{4}\int_{\gamma}\frac{e^{iz}+e^{-iz}}{1+z^2}dz$$
where $\gamma$ is the upper semicircle with radius $r$. Then I can evaluate the residue for $z=i$ (the radius is eventually going to tend to infinity) and via Jordan's Lemma I get
$$A = \frac{\pi}{4}(e^{-1} + e).$$
Now, my professor solved this integral in a very similar manner but he passed from 
$$A = \frac{1}{2} \int_{-\infty}^{\infty}\frac{\cos(x)}{1+x^2}dx = \frac{1}{2} \int_{-\infty}^{\infty}\frac{e^{ix}}{1+x^2}dx $$
I tried to reconstruct the steps that bring me from one form to the other but I am not capable of doing so. What am I missing here?
Thanks in advance to everyone who is going to participate.

Unfortunately your choice of function and curve don't work and is why proof of contours vanishing or not vanishing are important (I wish physicists would take note here).
Using the residue theorem and equating it to your integral relies on the integral along the circular arc vanishing. But at the top of the arc 
$$\frac{e^{iz}+ e^{-iz}}{1+z^2} \to \frac{e^{-y}+e^y}{1-y^2} \not\to 0$$ because it is exponentially growing, not decaying, as you take the radius of the arc to be larger and larger. This is in fact true for all points on the arc in the upper half plane, so this is not a problem that can be principal valued away by ignoring the imaginary axis.
