Calculate $\int_{-\infty}^{\infty}\frac{x}{(x^2+1)}\sin(ax)dx$ Calculate $$\int_{-\infty}^{\infty}\frac{x}{(x^2+1)}\sin(ax)dx$$
My try: 
$f(z)=\frac{z}{z^2+1}e^{iax}$ and then I thought using semi-circle on the imaginary axis and taking the imaginary part of the integral but when i take the imaginary i don't get the same function.
Any help is welcome.
 A: Let $I(a)=\int_{0}^{\infty}\frac{\sin ax}{x(x^2+1)}dx$. Then,
$$I’’(a) =- \int_{0}^{\infty}\frac{x\sin ax}{x^2+1}dx
= I(a) -\int_{0}^{\infty}\frac{\sin ax}{x}dx= I(a)- \frac\pi2
$$
which leads to $I(a)= \frac{\pi a}{2|a|}(1-e^{-|a|})$. Thus,
$$\int_{-\infty}^{\infty}\frac{x\sin ax }{x^2+1}dx
= -2I’’(a)= \frac{\pi a}{|a|}e^{-|a|}
$$
A: It is proved in Complex Analysis textbooks that if $A$ is a finite subset of $\Bbb C$ and if $f\colon\Bbb C\setminus A\longrightarrow\Bbb C$ is analytic and $\lim_{z\to\infty}f(z)=0$, then$$\int_{-\infty}^\infty f(z)e^{iaz}\,\mathrm dz=\begin{cases}\displaystyle2\pi i\sum_{w\in A,\ \operatorname{Im}w>0}\operatorname{res}(w,f(z)e^{iaz})&\text{ if }a>0\\-2\pi i\displaystyle\sum_{w\in A,\ \operatorname{Im}w<0}\operatorname{res}(w,f(z)e^{iaz})&\text{ if }a>0\end{cases}.$$So,\begin{align*}\int_0^\infty\frac x{x^2+1}\sin(ax)\,\mathrm dx&=\frac12\operatorname{Im}\left(\int_{-\infty}^\infty\frac{xe^{iax}}{x^2+1}\,\mathrm dx\right)\\&=\begin{cases}\pi e^{-a}&\text{ if }a>0\\-\pi e^a&\text{ if }a<0.\end{cases}\end{align*}
