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.
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*}