Evaluating $\int_{-\infty}^{\infty}\frac{x^2 \cos(x)}{(x^2+1)^2}dx$ by method of residues. Im trying to solve $$\int_{-\infty}^{\infty}\frac{x^2 \cos(x)}{(x^2+1)^2}dx$$ using the method of residues. This function has two simple poles at $x=\pm i$ and so $$\int_{-\infty}^{\infty}\frac{x^2 \cos(x)}{(x^2+1)^2}dx=2\pi i\text{Res}_{z=i }\frac{z^2 \cos(z)}{(z^2+1)^2}=2\pi i \lim_{z\to i} \frac d{dz}\Big[ (x-i)\frac{z^2 \cos(z)}{(z^2+1)^2}\Big]=2\pi i\lim_{z\to i}\frac d{dz}\Big[\frac{z^2\cos(z)}{(z+i)^2} \Big]=2\pi i \lim_{z\to i} \Big[ \frac{(z+i)^2(2z\cos z-z^2 \sin z)-2z^2(z+i)\cos z}{(z+i)^4} \Big]=2\pi i(-\frac{ei}{4})=\frac{\pi e}{4}$$
However wolfram alpha says that $$\int_{-\infty}^{\infty}\frac{x^2 \cos(x)}{(x^2+1)^2}dx=0$$
I'm almost certain that the residue calculated above is correct, so why am I not able to apply the method here?
 A: Let $C$ be a closed contour comprised of $(i)$ the real-line segment from $-R$ to $R$ and $(ii)$ the semi-circular arc of radius $R$, centered at the origin, and in the upper-half plane.  Then, we have for $R>1$
$$\begin{align}
\oint_C \frac{z^2e^{iz}}{(z^2+1)^2}\,dz&=2\pi i \text{Res}\left(\frac{z^2e^{iz}}{(z^2+1)^2},z=i\right)\\\\
&=2\pi i \lim_{z\to i}\frac{d}{dz}\left(\frac{z^2e^{iz}}{(z+i)^2}\right)\\\\
&=2\pi i \lim_{z\to i}\left(\frac{2ze^{iz}+iz^2e^{iz}}{(z+i)^2}-\frac{2z^2e^{iz}}{(z+i)^3}\right)\\\\
&=2\pi i \left(-ie^{-1}/4 +ie^{-1}/4\right)\\\\
&=0 \tag 1
\end{align}$$
We also have 
$$\begin{align}
\oint_C \frac{z^2e^{iz}}{(z^2+1)^2}\,dz&=\int_{-R}^R\frac{x^2e^{ix}}{(x^2+1)^2}\,dx+\int_0^\pi \frac{R^2e^{i2\phi}e^{iRe^{i\phi}}}{(R^2e^{i2\phi}+1)^2}\,iRe^{i\phi}\,d\phi \tag 2
\end{align}$$
As $R\to \infty$, the second integral on the right-hand side of $(2)$ approaches zero.  Therefore, putting everything together we find that 
$$\int_{-\infty}^\infty\frac{x^2e^{ix}}{(x^2+1)^2}\,dx=0$$
and therefore since $e^{ix}=\cos(x)+i\sin(x)$
$$\int_{-\infty}^\infty\frac{x^2\cos(x)}{(x^2+1)^2}\,dx=0$$
