# Contour Integral for Cosine and a rational function

I've been trying to figure out this integral via use of residues:

$$\int_{-\infty}^{\infty} \displaystyle \frac{\cos{5x}}{x^4+1}dx$$

The usual semicircle contour wont work for this guy as the integrated is unbounded. My idea came from a book I was reading on contour integration, where we let

$$f(z) = \displaystyle\frac{e^{(-5iz)}}{2(z^4+1)}+\displaystyle\frac{e^{(5iz)}}{2(z^4+1)}$$

And do the integral in the complex play as follows:

$\gamma_{1}= \text{The contour taken to be the top half of the circle in the counter clockwise direction}$ This contour uses the second term in $f(z)$

$\gamma_{2}= \text{The contour taken from$-R$to$R$on the real axis}$

$\gamma_{3}= \text{The contour taken to be the bottom half of the circle in the clockwise direction}$ This uses the first term in $f(z)$.

In the end, the contours $\gamma_{1}$ and $\gamma_{3}$ are bounded and will tend to $0$ as $R$ goes to infinity, so that we're left with the two integrals that we want.

My issue now is that when computing residues..everything seems to be cancelling out and I'm getting $0$. Should I take different contour? I'm really not sure what I did wrong.

Using $\gamma=[-R,R]\cup Re^{i[0,\pi]}$ and the simple poles at $\frac{1+i}{\sqrt2}$ and $\frac{-1+i}{\sqrt2}$ inside $\gamma$ \begin{align} \int_{-\infty}^\infty\frac{\cos(5x)}{x^4+1}\mathrm{d}x &=\mathrm{Re}\left(\int_\gamma\frac{e^{i5z}}{z^4+1}\mathrm{d}z\right)\\ &=\mathrm{Re}\left(2\pi i\left(\left[\frac{e^{i5z}}{4z^3}\right]_{z=\frac{1+i}{\sqrt2}} +\left[\frac{e^{i5z}}{4z^3}\right]_{z=\frac{-1+i}{\sqrt2}}\right)\right)\\ &=\mathrm{Re}\left(\frac{\pi}{2i}e^{-5/\sqrt2}\left(\frac{1+i}{\sqrt2}e^{i5/\sqrt2} -\frac{1-i}{\sqrt2}e^{-i5/\sqrt2} \right)\right)\\ &=\pi e^{-5/\sqrt2}\mathrm{Im}\left(\frac{1+i}{\sqrt2}e^{i5/\sqrt2}\right)\\ &=\pi e^{-5/\sqrt2}\mathrm{Im}\left(e^{i(5/\sqrt2+\pi/4)}\right)\\ &=\pi e^{-5/\sqrt2}\sin\left(\frac5{\sqrt2}+\frac\pi4\right) \end{align} Mathematica 8 agrees numerically, but its closed form involves complex functions and looks nothing like what I have above.
No need to compute two different integrals. Note that $\cos 5x = \operatorname{Re} e^{5ix}$. Put $$f(z) = \frac{e^{5iz}}{z^4+1}$$ and integrate over the boundary of a half-disc in the upper half-plane. On the semi-circle $C_R^+$: $$\left| \int_{C_R^+} \frac{e^{5iz}}{z^4+1} \right| \le \frac{1}{R^4-1} \cdot \pi R \to 0$$ as $R \to \infty$ since $|e^{5iz}| \le 1$ in the upper half-plane. Compute the relevant residues and finish off by taking the real part.