$$\int^{\infty}_{-\infty}\frac{\sin(ax)}{x(x^2+1)}dx=\pi(1-e^{-a}), \ a\ge0$$
I tried to solve but came up with $\pi(2-e^{-a}) $. Could you tell me where did I do the mistake?
if $x=z$ then $dz=dx$
$$\int_\gamma \frac{e^{iaz}}{z(z^2+1)}\quad and\quad z(z+i)(z-i)=0\quad \rightarrow z=0,z=\pm i$$
for $ z=0$ $$Res(f,0)=\lim_{z\to 0}\frac{z.e^{iaz}}{z(z^2+1)}=1$$
for $z=1$
$$Res(f,i)=\lim_{z\to i}\frac{(z-i).e^{iaz}}{z(z+i)(z-i)}=\lim_{z\to i}\frac{e^{iaz}}{z(z+i)}=\frac{e^{-a}}{-2}$$
$$\int_\gamma \frac{e^{iaz}}{z(z^2+1)}=\int_{-R}^{R}\frac{e^{iax}}{x(x^2+1)}dx+\int_\gamma \frac{e^{iaz}}{z(z^2+1)}=\pi i(1-\frac{e^{-a}}{-2})$$
$$\int_{-R}^{R}\frac{e^{iax}}{x(x^2+1)}=\int^{R}_{-R}\frac{\cos(ax)}{x(x^2+1)}dx+i\int_{-R}^R \frac{\sin(ax)}{x(x^2+1)}=i(2\pi - 2\pi \frac{e^{-a}}{2})$$
$$\rightarrow \int_{-R}^R\frac{\sin(ax)}{x(x^2+1)}=2\pi -2\pi \frac{e^{-a}}{2}=\pi(2-e^{-a}) $$
The integral depends on the value of $a$, which I assume is a real number.
Assuming that $a\ge 0$, You can use this kind of contour to integrate $f(z) = \dfrac{e^{iaz}}{z(z^2+1)}$. The point is that you have to go around the singularity at $z=0$. (An alternative is to follow Did's suggestion).
Using this contour, you obtain:
$$2\pi i Res(f,i) = \left(\int_R - \int_\epsilon\right) + \left(\int_r^R f(x) dx + \int_{-R}^{-r} f(x) dx\right),$$
$\int_R$ and $\int_\epsilon$ both represent integral of $f$ over the respective semicircles. A quick computation shows that $R\to \infty$ makes $\int_R\to 0$ and $\epsilon \to 0$ makes $\int_\epsilon\to i\pi$.
Therefore,
$$2\pi i Res(f,i) = - i\pi + \int_{-\infty}^\infty f(x) dx$$
Computing the residue and solving for the integral gives:
$$ \int \dfrac{\sin(ax)}{x(x^2+1)} dx = \pi (1-e^{-a})$$
For $a<0$, you can use a similar contour, but it has to be upside down from the one used above in order for the big $R$ contour to vanish as $R\to \infty$. The answer comes out to be $\pi (e^a -1)$.