Use residues to verify the given integral:$$\text{p.v.}\int_{-\infty}^{\infty}\frac{\sin(2x)}{x(x^2+1)^2}dx=\pi(\frac{1}{2}-e^{-2})$$
What I got -- by altering $\sin(2x)$ to its identity $e^{2iz}$ -- is: $$(\pi i+\frac{2\pi i}{e^2})$$ which looks similar to the answer but it is not correct.
The answer is actually
$$2 \pi \left ( \frac{1}{2} - \frac{1}{e^2}\right )$$
which I will show below.
The idea is that you need to split the sine into its exponential components in order to use the semicircular contours in the complex plane. That is, we consider
$$\oint_C dz \frac{e^{i 2 z}}{z (1+z^2)^2}$$
where $C$ is a semicircular contour in the upper half-plane, except we cut a small semicircular notch above the real axis about the origin in order to avoid the pole on the contour. In this way, the integral vanishes on the large semicircle as the radius of that semicircle goes to infinity. (Note that this is why we could not use the sine here, because the $e^{-i 2 z}$ component would diverge here.) By integrating about the small semicircle at the origin, we get
$$\begin{align}\oint_C dz \frac{e^{i z}}{z (1+z^2)^2} &= PV \int_{-\infty}^{\infty} dx \frac{e^{i 2 x}}{x (1+x^2)^2} + \lim_{\epsilon \rightarrow 0} \left[i \epsilon \int_{\pi}^0 d\phi \frac{e^{i 2 \epsilon e^{i \phi}}}{\epsilon (1+\epsilon^2 e^{i 2 \phi})^2}\right]\\ &= PV \int_{-\infty}^{\infty} dx \frac{e^{1 2 x}}{x (1+x^2)^2} - i \pi \end{align}$$
The above is equal to $i 2 \pi$ times the sum of the residues of the poles inside $C$. In this case, we have a double pole at $z=i$ as the only pole inside $C$. Thus the residue is
$$\begin{align}\text{Res}_{z=i} &= \lim_{z\rightarrow i}\frac{d}{dz} \left [(z-i)^2\frac{e^{i 2 z}}{z (1+z^2)^2} \right ]\\ &= \frac{d}{dz} \left [\frac{e^{i 2 z}}{z (z+i)^2} \right ]_{z=i}\\ &= \left[\frac{i 2 z (z+i)^2 - (z+i)^2 - 2 z (z+i)}{z^2 (z+i)^4} e^{i 2 z} \right ]_{z=i}\\ &= -\frac{1}{e^2} \end{align}$$
Therefore
$$PV \int_{-\infty}^{\infty} dx \frac{e^{i 2 x}}{x (1+x^2)^2} = i \pi - \frac{i 2 \pi}{e^2}$$
Now consider
$$\oint_{C'} dz \frac{e^{-i 2 z}}{z (1+z^2)^2}$$
where $C'$ is a semicircular contour in the lower half-plane, with a semicircular notch cut out below the real axis at the origin. The calculations are very similar to those above and I leave them for the reader. The result is
$$PV \int_{-\infty}^{\infty} dx \frac{e^{-i 2 x}}{x (1+x^2)^2} = -i \pi + \frac{i 2 \pi}{e^2}$$
Using
$$\sin{2 x} = \frac{e^{i 2 x}-e^{-i 2 x}}{2 i}$$
we subtract the above results and divide by $2 i$/ Note that we can drop the $PV$ from the integrals because the singularities at the origin cancel. The final result is
$$\int_{-\infty}^{\infty} dx \frac{\sin{2 x}}{x (1+x^2)^2} = 2 \pi \left ( \frac{1}{2} - \frac{1}{e^2}\right )$$
as stated above.