Evaluate the following improper integral. $$ \int^{+\infty}_{-\infty} \frac{x\sin 4x}{x^2-4x+8}dx \,  $$
My Thoughts: 
I know that I should start by changing the integral to: 
$$ \int^{+\infty}_{-\infty} \frac{x(\frac{e^{4ix}-e^{-4ix}}{2i})4x}{x^2-4x+8}dx \,  $$ and from there I should change them to the complex form using the definition $z=e^{ix}$.
I've been continuing to work through this problem but I get all mixed up when it comes time to manipulate the expression inside the integral so that I can find the singularities and residue  and apply the formulas. 
Should I split it up into three separate integrals? 
I would like to see a worked out solution to this problem. 
 A: We want the $$\text{Imag}\left(\int_{-\infty}^{\infty} \dfrac{x\exp(4ix)dx}{x^2-4x+8}\right)$$
Consider the contour integral
$$f(R) = \int_{[-R,R]\cup \Gamma_R} \dfrac{z\exp(4iz)dz}{z^2-4z+8} = \int_{-R}^R \dfrac{z\exp(4iz)dz}{z^2-4z+8} + \int_{\Gamma_R} \dfrac{z\exp(4iz)dz}{z^2-4z+8}$$
where $\Gamma_R$ is a semi-circle of radius $R$ on the upper half plane. Since the integrand encloses the pole $z=2+2i$, which is inside $[-R,R]\cup \Gamma_R$, we have
$$f(R) = 2\pi i \cdot \dfrac{(2+2i)\exp(4i(2+2i))}{(2+2i-2+2i)} = \pi(1+i)\exp(-8+8i)$$
Hence,
$$\lim_{R \to \infty} \left(\int_{-R}^R \dfrac{z\exp(4iz)dz}{z^2-4z+8} + \int_{\Gamma_R} \dfrac{z\exp(4iz)dz}{z^2-4z+8} \right) = \pi(1+i)\exp(-8+8i)$$
which gives us
$$\int_{-\infty}^{\infty} \dfrac{z\exp(4iz)dz}{z^2-4z+8} + \lim_{R \to \infty} \int_{\Gamma_R} \dfrac{z\exp(4iz)dz}{z^2-4z+8} = \pi(1+i)\exp(-8+8i)$$
Further, we have
$$\left \vert \lim_{R \to \infty} \int_{\Gamma_R} \dfrac{z\exp(4iz)dz}{z^2-4z+8}\right \vert \leq \lim_{R \to \infty}  \pi \left \vert \dfrac{f(R^2)}{g(R^2)} \int_0^{\pi}\exp\left(-4R \sin(t)\right)dt\right \vert = 0$$
Hence, we obtain that
$$\int_{-\infty}^{\infty} \dfrac{z\exp(4iz)dz}{z^2-4z+8} = \pi(1+i)\exp(-8+8i) = \dfrac{\pi}{e^8} (1+i)\exp(8i)$$
Taking the imaginary part we obtain
$$\text{Imag}\left(\dfrac{\pi}{e^8} (1+i)\exp(8i) \right) = \dfrac{\pi(\cos(8)+\sin(8))}{e^8}$$
A: Consider
$$\oint_C dz \frac{z \, e^{i 4 z}}{(z-2)^2+4} $$
where $C$ is a semicircle of radius $R$ in the upper half plane, with diameter along the real axis.  The contour integral is then equal to
$$\int_{-R}^R dx  \frac{x \, e^{i 4 x}}{(x-2)^2+4} + i R \int_0^{\pi} d\theta \, e^{i \theta} \frac{R e^{i \theta} \, e^{i 4 R e^{i \theta}}}{\left (R e^{i \theta}-2\right)^2+4}$$
As $R \to \infty$, the magnitude of the second integral vanishes because it is bounded by
$$2 \frac{R^2}{(R-2)^2} \int_0^{\pi/2} d\theta \, e^{-4 R \sin{\theta}} \le 2 \frac{R^2}{(R-2)^2} \int_0^{\pi/2} d\theta \, e^{-8 R \theta/\pi} \le \frac{\pi R}{4 (R-2)^2}$$
By the residue theorem, the contour integral is equal to $i 2 \pi$ times the residue at the pole $z=2+i 2$ within $C$.  Thus,
$$\int_{-\infty}^{\infty} dx \frac{x \, e^{i 4 x}}{(x-2)^2+4} = i 2 \pi \frac{(2 + i 2) e^{i 4 (2+i 2)}}{2 (i 2)} \\= \pi \, e^{-8} [( \cos{8} - \sin{8}) + i (\cos{8} + \sin{8})]$$
At this point, you may simply take the imaginary part of both sides to get
$$\int_{-\infty}^{\infty} dx \frac{x \, \sin{ 4 x}}{(x-2)^2+4} = \pi \, e^{-8} (\cos{8} + \sin{8}) $$
