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!
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?