Solve the improper integral with techniques of complex analysis This is an integral classified as "rational function multiplied by a trigonometric function", but I do not see how I could satisfy conditions of Jordan's lemma. Namely, it's obvious that singularities are $x = i$, $x = -i$ and $x = 0$, where all three are $\textit{first order poles}$ (hence, $x = 0$ satisfies conditions for residues $Im(z) > 0$ and $Im(z) = 0$), but what contour should I choose and how do I calculate the integral? Integral is $$\int_{-\infty}^{\infty} \frac {x - \sin x} {x^3(x^2 + 1)}dx.$$ Also, I've searched online for it thoroughly, but I haven't found anything about it. Any help is appreciated. Thank you.
 A: Think about the contour $C_1$ that starts at $z=\frac12$, follows the real axis from there to $z=-\frac12$, and then follows the circle $|z|=\frac12$ counterclockwise back to $z=\frac12$. There are no singularities except for the removable one at $z=0$ within or along the contour, so
$$\oint_{C_1}\frac{z-\sin z}{z^3\left(z^2+1\right)}dz=0$$
Thus if $C_2$ runs form $z=-R$ to $z=R$ along the real axis,
$$\begin{align}\int_{-R}^{R}\frac{x-\sin x}{x^3\left(x^2+1\right)}dx&=\int_{C_2}\frac{z-\sin z}{z^3\left(z^2+1\right)}dz\\
&=\int_{C_2}\frac{z-\sin z}{z^3\left(z^2+1\right)}dz+\int_{C_1}\frac{z-\sin z}{z^3\left(z^2+1\right)}dz\\
&=\int_{C_3}\frac{z-\frac{e^{iz}}{2i}}{z^3\left(z^2+1\right)}dz+\int_{C_3}\frac{\frac{e^{-iz}}{2i}}{z^3\left(z^2+1\right)}dz\end{align}$$
Where $C_3$ runs from $z=-R$ to $z=-\frac12$ along the real axis, from $z=-\frac12$ to $z=\frac12$ along the circle $|z|=\frac12$, and then to $z=R$ along the real axis. We close the first of the integrals above with a semicircle at $|z|=R$, enclosing the poles at $z=0$ and $z=i$ counterclockwise and the second below with a semicircle at $|z|=R$, enclosing the pole at $z=-i$ clockwise, and then take the limit as $R\rightarrow\infty$ of both integrals.  
Thus we get $2\pi i$ times the residues at $z=0$ and $z=i$ of the first integrand and $-2\pi i$ times the residue at $z=-i$ of the second integrand.
$$\int_{-\infty}^{\infty}\frac{x-\sin x}{x^3\left(x^2+1\right)}dx=2\pi i\left(-\frac34i+\frac i2-\frac{e^{-1}}{4i}\right)-2\pi i\left(\frac{e^{-1}}{4i}\right)=\frac{\pi}2-\frac{\pi}e$$
As in the comment of @Artificial Intelligence above.
