TITLE: Evaluate $\int \frac {\sin(x)}{x^2 + 4x + 5}dx$
QUESTION [7 upvotes]: Question:

Evaluate
  $$ \int \frac{\sin(x)}{x^2 + 4x + 5} dx=\int \frac {\sin(x)}{(x + 2)^2 + 1}dx $$

By using the change of variable $y = x + 2$ we have that $dy = dx$ then
$$I = \int \frac{\sin(y - 2)}{y^2 + 1} dy$$
$f = \sin(y - 2)$, $f' = \cos(y - 2)$
$g' = \frac {1} {y^2 + 1}$, $g = \arctan(y)$
$I = \sin(y - 2) \cdot \arctan(y) + \int \cos(y - 2)  \arctan(y) dy$
$I_1 = \int \cos(y - 2) \cdot \arctan(y) dy$
How can I solve?

REPLY [2 votes]: This answer is inspired by the tag used by the OP. 
You may find the value of $$\int_{-\infty}^{\infty} \frac{\sin (x)}{(x+2)^2 + 1} dx$$ by using complex integration. Consider the function $f(z) = \frac{1}{(z  +2)^2 +1}$ then $f(z) e^{iz}$ is analytic everywhere on and above the real axis except at the point $z = -2 + i$. 
Let $C_R$ be the upper half of the the circle $|z| = R$, with $R > 2 $  from $z = -R$ to $z = R$. 
Then integrating $f(z) e^{iz}$ yields  
$$\int_{-R}^{R} \frac{e^{ix}}{(x+2)^2 + 1} dx = 2\pi i \,\,\mathrm{Res}_{z = -2 + i}\,\, [f(z)e^{iz}] - \int_{C_R} f(z)e^{iz} dz \tag{*}$$
where $\mathrm{Res}_{z = -2 + i}\,\, [f(z)e^{iz}] = \frac{e^{-1}(\cos 2 - i\sin 2)}{2i}$ and by showing that $\int_{C_R} f(z)e^{iz} dz \to 0$ as $R \to \infty$ (why?) thus we have that the imaginary part of $(*)$ is 
$$\int_{-\infty}^{\infty} \frac{\sin (x)}{(x+2)^2 + 1} dx = \color{red}{-\frac{\pi\sin 2}{e}}$$
as $R \to \infty$.