evaluating $\int_{-\infty}^{\infty}{\frac{x\sin(2x)}{x^2+4}}\mathrm dx$ I want to calculate $\int_{-\infty}^{\infty}{\frac{x\sin(2x)}{x^2+4}}\mathrm dx$. Now I think the answer is $\pi/e^4$. Now the poles are cleary $2i, -2i$. When I try to then use the residue theorem I get that the integral is $0$, which I think is wrong.
What am I doing wrong exactly, can I not use the residue theorem here? 
 A: The trick to apply contours in this case is to write $\sin 2x = \frac1{2i} e^{2ix} +  \frac1{2i} e^{-2ix} $ and do two separate integrals.  
For the former, we have a contour going from $-\infty$ to $\infty$ along the $x$ axis, then returning n a large semicircle in the upper half plane.  The semicircle contributes zero because until the imaginary part is much bigger than the real part, the $\frac1 x$ behavior of $\frac{x}{x^2+4}$ will make the integral arbitrarily small, while after the imaginary part is much bigger than the real part, the exponential fall-off of $e^{2iz}$ as the imaginary part of $z$ grows positive will dominate over the linear growth of the circumference length. This contour encloses just the pole at $z=2i$ so this integral is
$$
\left. 2\pi i \frac{z\frac1{2i} e^{2iz}}{z+2i} \right|_{z = 2i} = 2\pi i\frac{(2i)\frac1{2i} e^{2i(2i)}}{(2i)+2i} = \frac{2\pi i e^{-4}}{4i}=\frac12\pi  e^{-4}
$$
For the $-\frac12 e^{-2ix} $ term, similar arguments have the contour returning in the lower half plane.  However, if we go from $-\infty$ to $+\infty$ along the real axis, we will have a clockwise path; so we will have to take the negative of the residue.  This term then gives
$$
\left. -2\pi i \frac{z\frac{-1}{2i} e^{-2iz}}{z-2i} \right|_{z = -2i} = -2\pi i\frac{(-2i)\frac{-1}{2i} e^{-2i(-2i)}}{(-2i)-2i} = -\frac{2\pi i e^{-4}}{-4i}=\frac12\pi  e^{-4}
$$
and we can then add those two terms giving $\pi e^{-4}$.
Your mistake may have been not to noice that in the lower half plane, if you go from $-\infty$ to $+\infty$ along the real axis, the direction of integration is not counterclockwise.
