I have to evaluate the following improper integral $$\int_{-\infty}^{\infty} \frac{\sin(x)}{x(x^2+1)} dx.$$ I used contour integration to evaluate this taking $f(z)$ as follows: $$f(z)=\frac{\sin(z)}{z(z^2+1)}.$$
$z=0,i,-i$ are the singularities of $f(z)$. But we can see that $z=0$ is simply a removable singularity and not a pole. While $z=i,-i$ are simple poles.
I chose the contour to be a large semicircle of radius $R$ and its diameter along the real axis from $-R$ to $R$. The only pole $z=i$ lies within the contour.
Next, I calculated the residue at $z=i$ which comes out to be equal to $$\frac{\sinh(1)i}{-2}= \frac{e-\frac{1}{e}}{-4}i.$$ Finally applying the residue theorem, we get the value of integral as: $$I= 2πi\left(\frac{e-\frac{1}{e}}{-4}i\right)= \frac{π(e-\frac{1}{e})}{2}.$$ This result is not the same as we get using the following $f(z)$: $$f(z)= \frac{e^{iz}}{z(z^2+1)}$$ which gives us value of the integral as $$I= π\left(1-\frac{1}{e}\right).$$ Why is this the case? Why don't the two approaches give the same result? Please help.
$g(z)=\frac{e^{iz}}{z(z^2+1)}$ works with this curve ( almost, see below) because $|e^{iz}|\leq 1$ for $\mathrm{Im}(z)\geq 0,$ so the integral of that function along the circle does converge to $0$ as $R\to \infty$ there.
But $|\sin(z)|$ can be large when $\mathrm{Im}(z)>0.$
Part of the confusion might be that $e^{iz}=\cos(z)+i\sin(z),$ so you might think when $|\sin(z)|$ is large, so is $e^{iz}.$ But remember, $\cos(z)$ and $\sin(z)$ are both complex, for complex $z,$ and the values cancel.
If $z=a+bi,$ with $a,b\in\mathbb R,$ $b\geq0.$ Then $|e^{iz}|=e^{-b}\leq 1.$
But $$|\sin(z)|\geq\left|\frac{e^{b}-e^{-b}}{2}\right|$$
So $|\sin(z)|$ can be very large when $b$ is large, and therefore, we can’t conclude the integral of the half-circle converges to $0$ as $R\to\infty.$
(*) The problem with the $g(z)$ case is that $g(z)$ has a pole at $0.$ So you’ll need to alter the curve to avoid $0.$
You can avoid the pole at $0$ by integrating instead: $$g_2(z)=\frac{e^{iz}-1}{z(z^2+1)}$$ removing the pole, and then take the imaginary part of the result.
Then $|e^{iz}-1|\leq 2$ when $\textrm{Im}(z)\geq0,$ so this still works.