How to evaluate $\int _{-\infty }^{\infty }\!{\frac {\cos \left( x \right) }{{x}^{4}+1}}{dx}$ How to evaluate the following integral?
$$
\int _{-\infty }^{\infty }\!{\frac {\cos \left( x \right) }{{x}^{4}+1}}{dx}
$$
Unlike this example, according to maple, the solution does not contain sine and cosine integrals. But how does it eavluate this kind of integrals? The method?

$$1.5442760\;\approx\;\pi\exp{\left( -\frac{\sqrt{2}}{2}\right)}
\sin\left(\frac{\pi}{4} + \frac{\sqrt{2}}{2}\right)
\;=\;\int_\mathbb{R}\; \frac{\cos(x)}{x^4+1}\, dx$$
holds true, but it is not the answer to the question.
Furthermore, I do not know, how Maple is doing to get it.

Generalising the proposed integral, let's proceed to determine
  $$I_p\:=\:\int_\mathbb{R}\; \frac{\cos x}{x^p+1}\, dx
\qquad\text{where $p\in\mathbb{N}$ is even}.$$

Consider $f(x)=1/(x^p+1)$. Using residues we are computing the Fourier transform
\begin{align}
\hat f(\omega)\: & =\;\int_\mathbb{R}\; \frac{e^{-i\omega x}}{x^p+1}\, dx \\[2.7ex]
 & =\;\int_\mathbb{R}\; \frac{\cos(\omega x)}{x^p+1}\, dx
\; -\;i\int_\mathbb{R}\; \frac{\sin(\omega x)}{x^p+1}\, dx
\end{align}
which is purely real since the last integral vanishes, its integrand
$\frac{\sin(\omega x)}{x^p+1}$ being an odd function of $x$ for every $\omega$. And it's immediate that $\,\hat f\,$ is an even function then.
Once $\,\hat f(\omega)\,$ is made explicit the sought values can be obtained via evaluation: $I_p=\hat f(1)$.
Jordan's lemma can be applied
to calculate $\,\hat f(\omega)$, by assuming $\omega\le 0$ and with the real axis and the (infinite) semicircular arc in the upper half plane as contour of integration.
How does the integrand behave on that arc, parametrised by
$Re^{i\varphi}$ with $R\gg 0$ and $0\le\varphi\le\pi\:$?
$$\left| \frac{e^{-i\omega R(\cos\varphi + i\sin\varphi)}}
{(Re^{i\varphi})^p +1} \right|
 \;=\; \frac{\left| e^{\omega R\sin\varphi} \right|}
{\left| {R^p e^{ip\varphi} +1} \right|}$$
The numerator is bounded above by $1$, and because of $p\ge 2$ the overall decrease is sufficient.
Let's turn to the residues
contributing to the value of the integral. They originate from the
$p$-th roots of $\,-1\,$ having positive imaginary part:
\begin{align}
z_k & \;=\;\exp\left(i(2k-1)\frac{\pi}{p}\right)
\quad\text{where }k=1,\ldots ,\frac{p}{2} \\
 & \;=\;\cos\theta_k + i\sin\theta_k,\quad\theta_k=(2k-1)\frac{\pi}{p}
\end{align}
Note the reflection symmetry with respect to the imaginary axis which we record for later need
$$\sin\theta_{\frac{p}{2}+1-k} = \sin\theta_k
\quad\text{and}\quad
\cos\theta_{\frac{p}{2}+1-k} = - \cos\theta_k .$$
Since $z_k$ is a simple root and the numerator $e^{-i\omega x}$ is non-zero, the corresponding residue is given by
\begin{align}
\operatorname{Res}(z_k) & \;=\; \frac{e^{-i\omega x}}{px^{p-1}}\Bigg|_{x=z_k}
 \;=\; \frac{e^{-i\omega (\cos\theta_k +i\sin\theta_k)}}{pz_k^{p-1}} \\[2.7ex]
 & \;=\; -\frac{1}{p} \exp(\omega \sin\theta_k)\,
e^{i\theta_k}e^{-i\omega\cos\theta_k}
\end{align}
When summing these up
from $\,k=1\,$ to $\,p/2\,$ the real parts will cancel pairwise due to the reflection symmetry$-$just "Go back to the roots!" If $\,p/2\,$ is odd, then $\,i\,$ belongs to the relevant root set, and the real part of that summand is zero anyway. After multiplying with $\,2\pi i\,$ we are done:
$$\hat f(\omega)\;=\;\frac{2\pi}{p}\sum_{k=1}^{p/2}\exp\big(-|\omega|\sin\theta_k\big)
\sin\big(\theta_k + |\omega|\cos\theta_k\big)$$
Until here $\omega\le 0$ was understood, to meet the conditions allowing for the calculus of residues. Upon introducing the absolute value of $\omega$, this assumption can be abandoned because $\hat f(\omega)$ is even.
Choosing $\,|\omega|=1$ we reach the goal initially set out:

$$I_p\;=\;\frac{2\pi}{p}\sum_{k=1}^{\frac{p}{2}} e^{-\sin\theta_k}\,
\sin(\theta_k +\cos\theta_k)\, ,\quad\theta_k=(2k-1)\frac{\pi}{p}$$

