Imagine you are given the following integral: $$ I = \int_{-\infty}^\infty\frac{\sin(x)}{x(x^2 + 1)} $$ If we transform the problem into a contour integral we have the following:
$$ \int_C \frac{e^{iz}}{z(z^2 + 1)}dz = 2 \pi i \sum_k \text{Res}(f, z_k) $$ if we perform the integration over the contour $C$, given by: $$ \gamma = [-R, -\varepsilon] \cup C_{\varepsilon} \cup [\varepsilon, R] \cup C_\Gamma $$ where $[z_1, z_2]$ denotes the segment that joins the points $z_1$ and $z_2$, and: $$ C_\varepsilon = \varepsilon e^{it}, \; \; t \in [\pi, 0] $$ $$ C_\Gamma = R e^{it}, \; \; t \in [0, \pi] $$ Further analyzation gives the following: $$ \int_C \frac{e^{iz}}{z(z^2 + 1)}dz = \lim_{(R, \varepsilon) \to (\infty, 0)}\int_{-R}^{-\varepsilon} + \int_{C_\varepsilon} + \int^{R}_{\varepsilon} = 2 \pi i \sum_k \text{Res}(f, z_k) $$ Hence, we finally have: $$ \int_{-\infty}^{\infty} \frac{e^{iz}}{z(z^2 + 1)}dz + \pi i \text{Res}(f, z = 0) = 2\pi i\text{Res}(f, z = i) $$ $$ \int_{-\infty}^{\infty} \frac{e^{iz}}{z(z^2 + 1)}dz = 2\pi i\text{Res}(f, z = i) - \pi i \text{Res}(f, z = 0) $$ where: $$ \text{Res}(f, z = i) = \frac{-1}{2e} $$ $$ \text{Res}(f, z = 0) = 1 $$
$$ \int_{-\infty}^{\infty} \frac{e^{iz}}{z(z^2 + 1)}dz = i \left ( -\pi - \frac{\pi}{e} \right) $$ $$ I = \text{Im} \left [ i \left ( -\pi - \frac{\pi}{e} \right) \right ] = -\pi - \frac{\pi}{e} $$ So the result of the integral is: $$ I = -\pi - \frac{\pi}{e} $$ which is wrong. I realised the term coming from the residue of $z = 0$ is wrong, and changing it sign would fix the result. I've calculate the residues with the formula and by calculating the $a_{-1}$ term of the Laurent Series the function. What mistake did I make? Is my line of reasoning wrong?