Using residues to compute complex integrals Let $\phi:\mathbb{C}\backslash\{\pm i,\pm 2i\}\rightarrow\mathbb{C}$ with
$\phi(z)=\frac{e^{iz}}{(z^2+1)^2(z^2+4)}$.

  
*
  
*How can I find
  $$\int_{-\infty}^\infty\frac{\cos x}{(x^2+1)^2(x^2+4)}dx$$
  using $\phi$?  
  
*Can I use the function $\psi:\mathbb{C}\backslash\{\pm i,\pm 2i\}\rightarrow\mathbb{C}$ with
  $\psi(z)=\frac{e^{-iz}}{(z^2+1)^2(z^2+4)}$ to compute the integral? Why/why not?
  

Thoughts:
1. I thought computing the residues of $i$ and $2i$ might be handy, but I'm not sure how to continue on this.
 A: Note that:
$$\int_{-\infty}^{\infty} \frac{\sin x}{(x^2+1)^2(x^2 + 4)} dx = 0$$
since the integrand is odd and the integral converges (absolutely). So:
$$\int_{-\infty}^{\infty} \frac{\cos x}{(x^2+1)^2(x^2 + 4)} dx = \int_{-\infty}^{\infty} \frac{\cos x}{(x^2+1)^2(x^2 + 4)} dx + i \int_{-\infty}^{\infty} \frac{\sin x}{(x^2+1)^2(x^2 + 4)} dx \\ = \int_{-\infty}^{\infty} \frac{e^{ix}}{(x^2+1)^2(x^2 + 4)} dx$$
Let $R > 0$ be large enough and $\Gamma_R = \gamma_R \cup [-R,R]$, where $\gamma_R$ is the upper half semi-circle of center $0$ and radius $R$. 
Using Residue theorem, compute $\int_{\Gamma_R} \phi$. Then, prove that $\int_{\gamma_R} \phi \to 0$.
Finally note that $\int_{\Gamma_R} \phi = \int_{\gamma_R} \phi + \int_{[-R,R]} \phi$ and that $\int_{[-R,R]} \phi = \int_{-R}^R  \frac{e^{ix}}{(x^2+1)^2(x^2 + 4)}dx$, which converges to your integral.
A: An alternative approach to Ahmed Hussein's one. If we consider, for any $\alpha >0$,
$$ I(\alpha)=\int_{0}^{+\infty}\frac{\cos(\alpha x)}{x^2+1}\,dx$$
we have:
$$ I''(\alpha)=-\int_{0}^{+\infty}\frac{x^2 \cos(\alpha x)}{x^2+1}=\int_{0}^{+\infty}\frac{\cos(\alpha x)}{x^2+1}\,dx = I(\alpha)$$
so $I(a)= k_1 e^{\alpha}+k_2 e^{-\alpha}$, and since $I(\alpha)\to 0$ as $\alpha\to +\infty$ by Riemann-Lebesgue lemma and $I(0)=\frac{\pi}{2}$, we have $I(\alpha)=\frac{\pi}{2}e^{-\alpha}$ and by parity:
$$ \forall \alpha\in\mathbb{R}, \qquad I(a)=\frac{\pi}{2}\,e^{-|\alpha|}.$$
We may recover the same formula by computing the Fourier transform of $e^{-|x|}$ by integration by parts, then applying Fourier inversion. At last we may notice that $$\frac{1}{(x^2+1)(x^2+4)}=\frac{1}{3}\left(\frac{1}{x^2+1}-\frac{1}{x^2+4}\right)$$
so, for any $\alpha >0$,
$$\begin{eqnarray*} J(\alpha)=\int_{0}^{+\infty}\frac{\cos(\alpha x)}{(x^2+1)(x^2+4)}&=&\frac{I(\alpha)}{3}-\frac{1}{3}\int_{0}^{+\infty}\frac{\cos(\alpha x)}{x^2+4}\,dx\\ &=&\frac{I(\alpha)}{3}-\frac{I(2\alpha)}{6}\end{eqnarray*} $$
and:

$$ \forall \alpha\in\mathbb{R},\qquad \int_{-\infty}^{+\infty}\frac{\cos(\alpha x)}{(x^2+1)(x^2+4)} = \color{red}{\frac{\pi}{6}\left(2 e^{-|\alpha|}-e^{-2|\alpha|}\right)}.$$

