Integral over the real axis using residues I have to evaluate the following integral
$$
\int_{-\infty}^\infty \frac{x\sin{x}}{x^2-4x+8}dx
$$
I know that for such integrals we can use residues and
$$
\int_{-\infty}^\infty \frac{x\sin{x}}{x^2-4x+8}dx = 2\pi i \sum_{k=0}^n \text{res}[f(z),a_k] + \lim_{R\to\infty}\int_{\Gamma_R} f(z)dz
$$
I see that $f(z) = \frac{x\sin{x}}{x^2-4x+8}$ has one singularity in the upper half of the plane which is $x = 2+2i$ and I have computed that res$[f(z),2+2i] = \left(\frac{1}{2}-\frac{i}{2}\right)\sin{(2+2i)}$, but I have problems evaluating the line integral. Usually we have shown that this goes to $0$ as $R$ gets large, but in this case it doesn't seem to be so. How can I go about evaluating the line integral? Thanks for any advice.
 A: This is a great question @MarkusPunnar.  I am sad to see that no one gave a convincing answer.
According to my Complex Analysis book:  To evaluate your integral we can examine the residues of the closely related $$\int_{-\infty}^\infty \frac{ze^{iz}}{z^2-4z+8}dz $$
The specific contour you wanted to look (the circular arc) at would be:
$$\lim_{R\to \infty} \int_0^\pi \frac{Re^{i\theta} e^{iRe^{i\theta}}}{R^2e^{i\theta}-4Re^{i\theta}+8}Re^{i\theta} d\theta$$
This expression is absurdly busy but it is cleaner than the expression you would get with $sin(z).$  The trick is to expand the $e^{Re^{i\theta}}$ term using Euler's formula.
This will yield the ugly but approachable
$$\lim_{R\to \infty} \int_0^\pi \frac{R^2e^{2i\theta}e^{-Rsin(\theta)} e^{iRcos(\theta)}}{R^2e^{i\theta}-4Re^{i\theta}+8} d\theta$$
The modulus of this function will converge to $0$ as $R\to\infty$ on account of the $e^{-Rsin(\theta)}$ over the interval $\theta \in (0,\pi)$
$$\lim_{R\to \infty} | \frac{R^2e^{2i\theta}e^{-Rsin(\theta)} e^{iRcos(\theta)}}{R^2e^{i\theta}-4Re^{i\theta}+8} | = \lim_{R\to\infty}\frac{1}{e^{Rsin(\theta)}} = 0$$
Now we can use residues to establish that:
$$\int_{-\infty}^\infty \frac{ze^{iz}}{z^2-4z+8}dz = (\pi cos(2)- \pi sin(2))e^{-2} + i (\pi cos(2)+\pi sin(2))e^{-2}$$
By comparing imaginary parts we finally establish that:
$$\int_{-\infty}^\infty \frac{xsinx}{x^2-4x+8}dx =  e^{-2}(\pi cos(2)+\pi sin(2))$$
A: For integrals of the form
$$\int_{-\infty}^{+\infty}R(x)e^{ix}dx$$
where $R$ is a rational function with a zero at infinity, consider a rectangle of vertexes
\begin{align}
&-X_1&
&X_2&
&X_2+iY&
&-X_1+iY
\end{align}
for $X_1,X_2,Y>0$ large enough.
Then we have
\begin{align}
&\left|\int_{X}^{X+iY}R(z)e^{iz}dz\right|\ll\frac 1X&
&\left|\int_{-X_1+iY}^{X_2+iY}R(z)e^{iz}dz\right|\ll(X_1+X_2)\frac{e^{-Y}}Y
\end{align}
