Evaluate the definite integral $ \int_{-\infty}^{\infty} \frac{\cos(x)}{x^4 +1} \ \ dx $ I am having more trouble with this problem then I feel like I should be. I set $ \ \cos(x) = e^{ix} \ $ and $ \ x^4 +1 = e^{\pi i /4} \ $ or $ \sqrt{i} \ $. I think I am suppose to do a residue to evaluate it but I'm not quite sure, was hoping someone has seen this problem before and can help me with writing out the steps, thanks!
 A: Consider this contour and consider a function $\displaystyle f(z) = \frac{e^{iz}}{z^4 + 1}$
The integral vanishes (as $R\to\infty$) on the circular curve by Jordan's lemma. Since only the roots $e^{i\pi/4}$ and $e^{i3\pi/4}$ lie inside the Contour, the integral becomes
$$\int_{-\infty}^{\infty} \frac{e^{iz}}{z^4 + 1}dz dz = 2 \pi i \left( \mathrm{Res}(f(z), e^{i\pi/4})+\mathrm{Res}(f(z), e^{i3\pi/4})\right)$$
Or, 
$$\int_{-\infty}^{\infty} \frac{e^{iz}}{z^4 + 1}dz = 2\pi i\left( \frac{e^{ie^{i\pi/4}}}{4e^{i3\pi/4}}+\frac{e^{ie^{i3\pi/4}}}{4e^{i9\pi/4}}\right )$$
Simplifying and comparing real parts we get, 
$$\color{blue}{\int_{-\infty}^{\infty} \frac{\cos(x)}{x^4 +1}  dx} = \color{red}{\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: I am going to attempt to draw up a general case for even powers of x in the denominator.
That is, find some sort of closed form for $$\displaystyle \int_{-\infty}^{\infty}\frac{\cos(x)}{x^{2n}+1}dx$$.
Consider $$\frac{e^{iz}}{z^{2n}+1}$$ and use a semicircle in the UHP centered at the origin. 
The poles are at  $$z=e^{\frac{2k+1}{2n}\pi i}$$ and are evenly spaced around a circle with radius 1 every $\frac{\pi}{n}$ intervals.
In general, one may factor:
$$\displaystyle \frac{1}{z^{2n}+1}=\sum_{k=0}^{n-1}\frac{1}{2n\left(e^{\frac{2k+1}{2n}\pi i}\right)^{2n-1}}\cdot \frac{1}{\left(z-e^{\frac{2k+1}{2n}\pi i}\right)}$$
but I am omitting the portion that does not contribute because they are outside the contour.
So,  $$\displaystyle 2\pi i Res\left(e^{\frac{2k+1}{2n}\pi i}\right)=2\pi i\frac{e^{ie^{\frac{2k+1}{2n}\pi i}}}{2n\left(e^{\frac{2k+1}{2n}\pi i}\right)^{2n-1}}$$
summing these residues results in:
$$\displaystyle \frac{\pi i}{n}\sum_{k=0}^{n-1}\frac{e^{ie^{\frac{2k+1}{2n}\pi i}}}{\left(e^{\frac{2k+1}{2n}\pi i}\right)^{2n-1}}........(1)$$
For the outer edges of the contour along the x axis and up around the arc:
$$\displaystyle \int_{-\infty}^{0}\frac{e^{ix}}{x^{2n}+1}dx+\int_{0}^{\infty}\frac{e^{ix}}{x^{2n}+1}dx+\int_{0}^{\pi}\frac{e^{iRe^{i\theta}}iRe^{i\theta}}{1+R^{2n}e^{2ni\theta}}d\theta$$
The first two integrals may be combined, and the third one tends to 0 due to the usual $e^{-R\sin\theta}$ factor that disappears as $R\to \infty$.
Hence, by Cauchy's Theorem, the integral is equal to the sum of the residues at the poles in (1).  And, by Euler's formula, the final closed form can be written in terms of cos and sin. Note the imaginary part vanishes. 
$$\displaystyle \int_{-\infty}^{\infty}\frac{\cos(x)}{x^{2n}+1}dx=\frac{\pi}{n}\sum_{k=0}^{n-1}e^{-\sin(\frac{2k+1}{2n}\pi)}\sin\left(\frac{2k+1}{2n}\pi +\cos\left(\frac{2k+1}{2n}\pi\right)\right)$$
As a check, let n = 2, and one obtains:
$$\displaystyle \pi e^{\frac{-1}{\sqrt{2}}}\sin\left(\frac{1}{\sqrt{2}}+\frac{\pi}{4}\right)$$
