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?
 A: This can be done using residues, with the function $f(z) = \exp(i z)/(z^4 + 1)$
and a contour that goes along the real axis and returns on a circular arc in the upper half plane.  
A: $$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}$$

A: Consider $f(z) = \exp(iz)/(z^4+1)$. Simple poles of $a(z)=\frac{b(z)}{c(z)}$ at $z_0$ have a residue of $\frac {b(z_0)}{c'(z_0)}$ at $z_0$. Thus, it can be seen that for any root $z_0$ of $z^4+1$, its residue is
$$\operatorname*{Res}_{z=z_0} f(z) = \frac{\exp(iz_0)}{4z_0^3}$$
Consider a semicircular contour of infinite radius, which, by Jordan's lemma, does not receive a contribution by the rounded part. There are two roots in this contour, $z_1 = (1+i)/\sqrt 2$ and $z_2 = (i-1)/\sqrt 2$. The residues at these poles are
$$r_1 = \operatorname*{Res}_{z = z_1}f(z) = \frac{\exp\left(\frac{i-1}{\sqrt 2}\right)}{(-2+2 i) \sqrt 2}$$
$$r_2 = \operatorname*{Res}_{z = z_2}f(z) = \frac{\exp\left(\frac{-1-i}{\sqrt 2}\right)}{(2+2 i) \sqrt 2}$$
Then,
$$I = \int_{-\infty}^\infty f(z)\,dz = 2\pi i (r_1+r_2) = \frac{\pi e^{-\frac{1}{\sqrt 2}} \left(\sin\left(\frac{1}{\sqrt 2}\right) + \cos\left(\frac{1}{\sqrt 2}\right)\right)}{\sqrt 2}$$
A: This is a two-sided variant of 
$$\int_0^\infty \frac{\cos(ax)}{b^4+x^4}dx=\frac{\pi\sqrt 2}{4b^3}\exp\left(-\frac{ab}{\surd 2}\right)\left[\cos\left(\frac{ab}{\surd 2}\right)+\sin\left(\frac{ab}{\surd 2}\right)\right].$$ My method is looking this up under item 3.727.1 in the Gradsteyn/Ryzhik tables.
