Calculating the integral $\int_{-\infty}^{\infty} x\sin(x)/(x^2+1)^2 dx$ I need help calculation the integral $\int_{-\infty}^{\infty} x\sin(x)/(x^2+1)^2 dx$
I am getting confused on how to integrate around $\pm i$. I think I'll have to use $\gamma = Re^{i\theta}$ where $|R|\leq n$ for $n\geq1$
 A: Let us define 
$$ g(a) = \int_{0}^{+\infty}\frac{x\sin(ax)}{(x^2+1)^2}\,dx $$
for $a\in\mathbb{R}^+$. Our integral is clearly $2\,g(1)$ by parity. We have
$$ \mathcal L g(s) = \int_{0}^{+\infty}\frac{x^2}{(s^2+x^2)(1+x^2)^2}\,dx = \frac{\pi}{4(1+s)^2} $$
by partial fraction decomposition, and 
$$ g(a) = \frac{\pi a}{4}e^{-a} $$
by the inverse Laplace transform. It follows that the original integral equals $\color{blue}{\frac{\pi}{2e}}$.
A: $$\int_{-\infty}^\infty\frac{x\sin x}{(x^2+1)^2}\mathrm dx=\mathfrak I\left\{\int_{-\infty}^\infty\frac{xe^{ix}}{(x^2+1)^2}\mathrm dx\right\}$$ 
Let us compute this integral. It is given by a contour in the complex plane that runs along the real axis. Since the exponential on top decays as $|x|\to\infty$ in the upper half plane, this is where we choose to close the contour. Therefore we have a semicircular contour in the upper half plane, of the form $Re^{i\theta}$ for $R>1$ and $\theta\in[0,\pi]$. Let us denote this contour by $\gamma_R$. 
$$\lim_{R\to\infty}\int_{\gamma_R} \frac{xe^{ix}}{(x^2+1)^2}\mathrm dx=\int_{-\infty}^{\infty}\frac{xe^{ix}}{(x^2+1)^2}\mathrm dx+\lim_{R\to\infty}\int_0^\pi\frac{Re^{i\theta}e^{iRe^{i\theta}}}{(R^2e^{2i\theta}+1)^2}iRe^{i\theta}\mathrm d\theta\tag1$$
Now we want to show that this second integral is zero in the limit as $R\to\infty$.
$$\begin{align}\left|\int_0^\pi \frac{Re^{i\theta}e^{iRe^{i\theta}}}{(R^2e^{2i\theta}+1)^2}iRe^{i\theta}\mathrm d\theta\right|&\le\int_0^\pi\left|\frac{Re^{i\theta}e^{iRe^{i\theta}}}{(R^2e^{2i\theta}+1)^2}iRe^{i\theta}\right|\mathrm d\theta\\&\le\int_0^\pi\left|\frac{R^2e^{-R\sin \theta}}{(R^2-1)^2}\right|\mathrm d\theta\end{align}$$
$\int_0^\pi e^{-R\sin\theta}\mathrm d\theta$ is finite, and in the limit as $R\to\infty$, the prefactor tends to zero, so the second integral in $(1)$ is zero.
So we have $$\int_{-\infty}^{\infty}\frac{xe^{ix}}{(x^2+1)^2}\mathrm dx=\lim_{R\to\infty}\int_{\gamma_R} \frac{xe^{ix}}{(x^2+1)^2}\mathrm dx\tag2$$
We evaluate the RHS of $(2)$ by residue calculus. The contour encloses a pole at $x=i$, of order $2$. We evaluate the residue at the pole. 
$$\text{Res}\left(\frac{xe^{ix}}{(x^2+1)^2},i\right)=\lim_{x\to i}\frac{d}{dx}\left(\frac{xe^{ix}(x-i)^2}{(x^2+1)^2}\right)=\lim_{x\to i}\frac{d}{dx}\left(\frac{xe^{ix}}{(x+i)^2}\right)=\frac1{4e}$$after some calculations. 
Therefore the RHS of $(2)$ is $$2\pi i\cdot \text{Res}\left(\frac{xe^{ix}}{(x^2+1)^2},i\right)=\frac{\pi i }{2e}$$
Since the integral we wish to calculate is the imaginary part of the LHS of $(2)$, the final answer is $$\frac{\pi}{2e}.$$
