Evaluate $\int_{-\infty}^{\infty}\frac{z \sin (z)}{\left(z^2+1\right) \left(z^2+2\right)} \mathrm{d}z$ I need help integrating $$\int_{-\infty}^{\infty}\frac{z \sin (z)}{\left(z^2+1\right) \left(z^2+2\right)} \mathrm{d}z$$
I calculated the integral over the closed upper half circle in the complex plane which is $\pi(\sinh(\sqrt2) - \sinh(1))$.
Then if I calculate the integral over $z = R e^{i\phi}$ for $\phi \in [0, \pi]$, and do the limit $R$ to $\infty$, the integral must be zero. And it follows that
$$\int_{-\infty}^{\infty}\frac{z \sin (z)}{\left(z^2+1\right) \left(z^2+2\right)}\mathrm{d}z = \pi(\sinh(\sqrt2) - \sinh(1))$$
But Wolfram Alpha says this is false.
What did I do wrong?
 A: If you let $ \displaystyle f(z) = \frac{z \sin z}{(z^{2}+1)(z^{2}+2)}$, the integral doesn't go to zero along the upper half of $|z|=R$ as $R \to \infty$.
Instead let $ \displaystyle f(z) = \frac{z e^{iz}}{(z^{2}+1)(z^{2}+2)} $.
By Jordan's lemma, the integral along the upper half of $|z|=R$ goes to zero as $R \to \infty$.
http://en.wikipedia.org/wiki/Jordan%27s_lemma
There are two simple poles inside of the closed contour at $z=i$ and $z=i \sqrt{2}$.
So $$\int_{-\infty}^{\infty} \frac{x e^{ix}}{(x^{2}+1)(x^{2}+2)}  \ dx = 2 \pi i \Big( \text{Res}[f(z),i] + \text{Res}[f(z),i \sqrt{2} \Big)$$
where
$$ \text{Res}[f(z),i] = \lim_{z \to i} \ (z-i) \frac{z e^{iz}}{(z^{2}+1)(z^{2}+2)} = \frac{ie^{-1}}{(2i)(1)} = \frac{1}{2e}$$
and
$$ \text{Res}[f(z),i\sqrt{2}] = \lim_{z \to i \sqrt{2}} \ (z-i\sqrt{2}) \frac{z e^{iz}}{(z^{2}+1)(z^{2}+2)} = \frac{i \sqrt{2} e^{-\sqrt{2}}}{(-1)(2 i \sqrt{2})} = - \frac{e^{-\sqrt{2}}}{2}$$
Then
$$\int_{-\infty}^{\infty}\frac{x e^{ix}}{(x^{2}+1)(x^{2}+2)} \ dx = 2 \pi i \left( \frac{1}{2e} - \frac{e^{-\sqrt{2}}}{2} \right)= i \pi\left(\frac{1}{e} - e^{-\sqrt{2}} \right)$$
Now just equate the imaginary parts on both sides of the equation.
