how could we compute this infinite real integral using complex methods?

$\int^{\infty}_{-\infty} \frac{cos(x)}{x^4+1}dx$

I know a similar result, but I’m not sure if I can take it for granted, that $\int^{\infty}_{-\infty} \frac{cos(x)}{x^2+1}dx = \frac{\pi}{e}$

The section in the book is related to Cauchy’s Integral Formulas and Liuville’s th’m, but I’m not sure how to apply these here.

Solutions Collecting From Web of "how could we compute this infinite real integral using complex methods?"

Use contour $C$ a semicircle of radius $R$ with its bottom the $\Re z$-axis. The contour is depicted in the figure below for $R=5$.
Figure 1
Then
$$\oint_C\frac{e^{iz}}{z^4+1}dz=\int_{-R}^R\frac{e^{ix}}{x^4+1}dx+\int_0^{\pi}\frac{e^{-R\sin\theta+iR\cos\theta}}{R^4e^{4i\theta}+1}iRe^{i\theta}d\theta$$
Now
$$\lim_{R\rightarrow\infty}\int_{-R}^R\frac{e^{ix}}{x^4+1}dx=\int_{-\infty}^{\infty}\frac{\cos x}{x^4+1}dx$$
Because $\frac{i\sin x}{x^4+1}$ is an odd function of $x$. Also, for $R>1$,
$$\left|\int_0^{\pi}\frac{e^{-R\sin\theta+iR\cos\theta}}{R^4e^{4i\theta}+1}iRe^{i\theta}d\theta\right|\le\int_0^{\pi}\frac{R\,d\theta}{R^4-1}=\frac{\pi R}{R^4-1}\rightarrow0$$
as $R\rightarrow\infty$. So that means that
$$\int_{-\infty}^{\infty}\frac{\cos x}{x^4+1}dx=2\pi i\times\sum(\text{residues in upper half-plane})$$
There are only $2$ poles there, at $\omega_1=\frac{1+i}{\sqrt2}$ and at $\omega_2=\frac{-1+i}{\sqrt2}$. Using L’Hopital’s rule,
$$\begin{align}\int_{-\infty}^{\infty}\frac{\cos x}{x^4+1}dx&=2\pi i\left[\lim_{z\rightarrow\omega_1}\frac{(z-\omega_1)e^{iz}}{z^4+1}+\lim_{z\rightarrow\omega_1}\frac{(z-\omega_2)e^{iz}}{z^4+1}\right]\\
&=2\pi i\left[\lim_{z\rightarrow\omega_1}\frac{e^{iz}}{4z^3}+\lim_{z\rightarrow\omega_2}\frac{e^{iz}}{4z^3}\right]\\
&=2\pi i\left[\frac{e^{i\omega_1}}{4\omega_1^3}+\frac{e^{i\omega_2}}{4\omega_2^3}\right]=-\frac{\pi i}2\left[\omega_1e^{i\omega_1}+\omega_2e^{i\omega_2}\right]\\
&=-\frac{\pi i}2\left[\frac{1+i}{\sqrt2}e^{\frac{-1+i}{\sqrt2}}+\frac{-1+i}{\sqrt2}e^{\frac{-1-i}{\sqrt2}}\right]\\
&=-\frac{\pi i}{2\sqrt2}e^{\frac{-1}{\sqrt2}}\left[\cos\frac1{\sqrt2}+i\sin\frac1{\sqrt2}+i\cos\frac1{\sqrt2}-\sin\frac1{\sqrt2}\right]\\
&-\frac{\pi i}{2\sqrt2}e^{\frac{-1}{\sqrt2}}\left[-\cos\frac1{\sqrt2}+i\sin\frac1{\sqrt2}+i\cos\frac1{\sqrt2}+\sin\frac1{\sqrt2}\right]\\
&=\frac{\pi}{\sqrt2}e^{\frac{-1}{\sqrt2}}\left[\sin\frac1{\sqrt2}+\cos\frac1{\sqrt2}\right]\end{align}$$

Remark: Wolfram|Alpha agrees with this result.