Contour integration to evaluate a real-valued integral I am evaluating this integral:
$$\int_{-\infty}^{\infty} \frac{\sin x}{x(x^2+1)^2}\,dx$$
with the formula
$$\int_{-\infty}^{\infty} f(x) \sin(sx) dx = 2\pi \sum\text{Re } \text{Res}[f(z) e^{isz}]$$
where the sum is over the residues in upper half plane.
So since the only two singularities that are inside the upper half plane are at $z = 0$ and $z=i$, I found that
$$\begin{align}
2\pi \sum\text{Re } \text{Res}\left(f(z) e^{isz}\right) &= 2 \pi \left(\text{Re }  \text{Res}_{z= 0}\left[\frac{1}{z (z^2+1)^2} e^{i z}\right]
+ \text{Re } \text{Res}_{z= i}\left[\frac{1}{z (z^2+1)^2} e^{i z}\right]\right) \\\\
  &=2 \pi \left(1 + \frac{-3}{4e}\right)
\end{align}$$
I am pretty sure that I calculated the two residues correctly, since in mathematica
Residue[E^(I z)/(z (z^2 + 1)^2), {z, 0}]

is $1$ and
Residue[E^(I z)/(z (z^2 + 1)^2), {z, I}]

is $\frac{-3}{4e}$
But evaluating the integral
Integrate[Sin[x]/(x (x^2 + 1)^2), {x, -Infinity, Infinity}]

mathematica gives $\pi - \frac{3 \pi}{2e}$.
I am wondering if this is because I did something wrong somewhere or if it is because mathematica gives the wrong answer.
Thank you!
 A: The inclusion of the residue at $z=0$ is not correct.  Rather, we begin by writing
$$\int_{-\infty}^\infty \frac{\sin(x)}{x(x^2+1)^2}\,dx=\text{Im}\left(\text{PV}\int_{-\infty}^\infty \frac{e^{ix}}{x(x^2+1)^2}\,dx\right)$$
where the Cauchy Principal Value is given by
$$\text{PV}\int_{-\infty}^\infty \frac{e^{ix}}{x(x^2+1)^2}\,dx=\lim_{\varepsilon\to 0^+}\int_{|x|>\varepsilon}\frac{e^{ix}}{x(x^2+1)^2}\,dx$$

Next, we move to the complex plane.  Ler $R>1$, $\varepsilon>0$, and $C$ be the contour in the upper-half plane that is comprised as $(i)$ the straight line paths from $-R$ to $-\varepsilon$ and from $\varepsilon$ to $R$, $(ii)$ the semi-circular arc centered at $z=0$ with radius $\varepsilon$ from $-\varepsilon$ to $\varepsilon$, and $(iii)$ the semi-circular arc centered at $z=0$ with radius $R$ from $R$ to $-R$.  Note that $z=0$ is excluded from the interior region bounded by $C$.
Then, we have can write
$$\begin{align}
\oint_{C}\frac{e^{iz}}{z(z^2+1)^2}\,dz&=\text{PV}\int_{-\infty}^\infty \frac{e^{ix}}{x(x^2+1)^2}\,dx\\\\
&+\int_{\pi}^0 \frac{e^{i\varepsilon e^{i\phi}}}{\varepsilon e^{i\phi}((\varepsilon e^{i\phi})^2+1)^2}\,i\varepsilon e^{i\phi}\,d\phi\\\\
&+\int_0^{\pi} \frac{e^{iR e^{i\phi}}}{R e^{i\phi}((R e^{i\phi})^2+1)^2}\,iR e^{i\phi}\,d\phi\tag1
\end{align}$$
As $R\to \infty$, the last integral on the right-hand side of $(1)$ approaches $0$.
As $\varepsilon\to0^+$, the second integral on the right-hand side of $(1)$ approaches $-i\pi$.
Since $C$ has excluded the $z=0$, the only residue implicated is at $z=i$.  Hence, we find
$$\text{PV}\int_{-\infty}^\infty \frac{e^{ix}}{x(x^2+1)^2}\,dx=i\pi +\text{Res}\left(\frac{e^{iz}}{z(z^2+1)^2}, z=i\right)\tag2$$
Now, calculate the residue at $z=i$ and take the imaginary part of both sides of $(2)$.  Can you finish now?
A: Since $z=0$ is a single pole of $f(z)$ on the boundary of the upper semicircle, it should be multiplied in $\pi$ rather than $2\pi$.
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\on}[1]{\operatorname{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
$\ds{\bbox[5px,#ffd]{}}$

\begin{align}
&\bbox[5px,#ffd]{\int_{-\infty}^{\infty}{\sin\pars{x} \over x\pars{x^{2} + 1}^{2}}\,\dd x} =
\Im\int_{-\infty}^{\infty}{\expo{\ic x} - 1\over x\pars{x^{2} + 1}^{2}}\,\dd x
\\[5mm] = &\
\Im\braces{2\pi\ic\,\lim_{x \to \ic}\,\totald{}{x}
\bracks{\pars{x - \ic}^{2}\,{\expo{\ic x} - 1\over x\pars{x^{2} + 1}^{2}}}}
\\[5mm] = &\
2\pi\,\Re\braces{\lim_{x \to \ic}\,\totald{}{x}
\bracks{{\expo{\ic x} - 1\over x\pars{x + \ic}^{2}}}}
\\[5mm] = &\
2\pi\,\Re\bracks{\lim_{x \to \ic}\
{\expo{\ic x}\pars{\ic x^{2} - 4x - \ic} + 3x + \ic \over
x^{2}\,\pars{x + \ic}^{3}}}
\\[5mm] = &\
\bbx{\pi - {3\pi \over 2\expo{}}} \approx 1.4080
\\ &
\end{align}
