Integral $ \int_{-\infty}^{+\infty} \frac{\cos(4x)}{x^2 + 2x + 2} \, dx$ I am trying to evaluate this very long definite integral given below:
$$ \int_{-\infty}^{+\infty} \frac{\cos(4x)}{x^2 + 2x + 2} \, dx$$
The direction it can go is by decomposing the denominator to $(x−i+1)$ and $(x+i+1)$ and then taking a partial fraction as:
$$ \frac{i\cos(4x)}{2(x−i+1)} - \frac{i\cos(4x)}{2(x−i+1)}.  $$
The online mathematical integral solvers follow this procedure, which ends up with a long and ugly solution to this integral. Is there a better way to go about this integral, and are there any elegant solutions?
Thanks for your time!
 A: Let $x+1=t$. Then,
\begin{align}
I=& \int_{-\infty}^{+\infty} \frac{\cos(4x)}{x^2 + 2x + 2} \, dx
=\cos4 \int_{-\infty}^{+\infty} \frac{\cos(4t)}{t^2 +1} \, dt
\end{align}
where the odd $\sin 4t$ term vanishes upon integration. Denote $J(a)=\int_{0}^{\infty} \frac{\cos(at)}{t^2 +1} dt$.
Then
$$J’(a)=-\frac\pi2+ \int_{0}^{\infty} \frac{\sin(at)}{t(t^2 +1)} dt,\>\>\>\>\>J’’(a)=J(a)
$$
With $J(0) = -J’(0)= \frac\pi2$, solve for $J(a)= \frac\pi2 e^{-a}$. Thus,
$$I=2 \cos4 J(4) =\pi e^{-4} \cos4$$
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
With $\ds{r \equiv -1 + \ic}$:
\begin{align}
\int_{-\infty}^{\infty}{\cos\pars{4x} \over x^{2} + 2x + 2}\,\dd x & =
\Re\int_{-\infty}^{\infty}{\expo{4\ic x} \over \pars{x - r}\pars{x - \overline{r}}}\,\dd x =
\Re\bracks{2\pi\ic\,{\expo{4\ic r} \over r - \overline{r}}}
\\[5mm] & =
\Re\bracks{2\pi\ic\,{\expo{-4\ic}\expo{-4} \over 2\ic}} =
\bbx{\pi\expo{-4}\cos\pars{4}}\ \approx\  -0.0376
\end{align}
A: 
Evaluation using contour integration:
Consider $\displaystyle \oint_\Gamma f(z)\, \mathrm{dz} $ where $\displaystyle f(z) = \frac{e^{4iz}}{z^2+2z+2}$ and $\Gamma$ is the contour that goes along the real line from $−a$ to $a$ and then counterclockwise along a semicircle centered at $0$ from $a$ to $−a$. $f$ has simple poles at $z = -1 \pm i$, only $z_1 = -1 + i$ of which is contained in $\Gamma$.
Calculating the residue,
$$ \begin{aligned} \text{Res}(f, z_1) & = \lim _{z \to -1+i} \bigg[(z+1-i)\frac{e^{4iz}}{(z+1-i)(z+1+i)}\bigg] \\& = \lim _{z \to -1+i} \bigg[\frac{e^{4iz}}{(z+1+i)}\bigg] \\& = -\frac{1}{2} i e^{-4}\cdot e^{ - 4 i}.\end{aligned} $$
By the residue theorem,
$$\displaystyle \begin{aligned} \oint_\Gamma f(z)\, \mathrm{dz} & = 2i\pi \sum \text{Res}(f, z_1) \\& = 2i\pi \cdot \left( -\frac{1}{2} i e^{-4}\cdot e^{ - 4 i}\right) \\& = π e^{-4}\cos(4) - i π e^{-4}\sin(4).\end{aligned}$$
Since $\Gamma$ can be split into the interval from $-a$ to $a$ and the semicircle arc, we may write:
$$\displaystyle \begin{aligned} \int_{-a}^{a}+\int_\text{arc}& =\oint_\Gamma f(z)\, \mathrm{dz} \\& = π e^{-4}\cos(4) - i π e^{-4}\sin(4)\end{aligned} $$
Taking the limit as $a \to \infty$, the integral along the arc goes to $0$ as it satisfies Jordan's lemma, and $$\displaystyle \begin{aligned} \int_{-a}^a & \to \int_{-\infty}^{\infty} \frac{e^{4ix}}{x^2+2x+2}\, \mathrm{dx} \\& = π e^{-4}\cos(4) - i π e^{-4}\sin(4).\end{aligned} $$
or
$$\displaystyle \begin{aligned} & \int_{-\infty}^{\infty} \frac{\cos{4x}}{x^2+2x+2}\, \mathrm{dx}+i\int_{-\infty}^{\infty} \frac{\sin{4x}}{x^2+2x+2}\, \mathrm{dx} \\& = π e^{-4}\cos(4) - i π e^{-4}\sin(4) \end{aligned}$$
Comparing the real and imaginary parts we find that $$\begin{aligned} \int_{-\infty}^{\infty} \frac{\cos{4x}}{x^2+2x+2}\, \mathrm{dx} = π e^{-4}\cos(4).\end{aligned}$$

Evaluation using Laplace transform:
If we let  $\displaystyle f(t) = \int_{-\infty}^{\infty}\frac{\cos(tx)}{x^2+2x+2}\;\mathrm{dx}$, then we seek $f(4)$.
Taking the Laplace transform of $f$,
$$\begin{aligned}  \mathcal{L}[f(t)] & = \int_{-\infty}^{\infty}\int_0^\infty\frac{\cos(tx)}{x^2+2x+2}e^{-ts}\,\mathrm{dt}\;\mathrm{dx} \\& = \int_{-\infty}^{\infty}\frac{s}{(s^2 + x^2) (2 + 2 x +  x^2)} \;\mathrm{dx} \\& = \frac{π (1 + s)}{2+2s+s^2} \\& \end{aligned}$$
Taking the inverse Laplace transform:$$\displaystyle \mathcal{L}^{-1}\left[\frac{π (1 + s)}{2+2s+s^2}\right] = \pi e^{-t} \cos(t) \implies f(4) = \pi e^{-4}\cos(4).$$

