Computing real definite integral using residue theorem I am trying to solve integral $\int_{-∞}^\infty \frac{cos(x)dx}{(x^2+a^2)(x^2+b^2)}$ using residue theorem. I found example of that with very similair integral, which is $\int_{0}^\infty \frac{cos(x)dx}{x^2+b^2}$. Everything would be clear, except one thing. When we substitute x $\to$ z and make our complex function, in the example cos(x) is replaced by $e^{ix}$. Why only $e^{ix}$, and not $\frac{e^{ix} + e^{-ix}}{2}$, since cos(x) = $\frac{e^{ix} + e^{-ix}}{2}$? Does this mean, that I should use this substitution on my integral, too?
 A: Note that $\cos(x)=\text{Re}(e^{ix})$.  Hence, we can write
$$\int_{-\infty}^\infty \frac{\cos(x)}{(x^2+a^2)(x^2+b^2)}\,dx=\operatorname{Re}\left(\int_{-\infty}^\infty \frac{e^{ix}}{(x^2+a^2)(x^2+b^2)}\,dx\right)\tag1$$
which facilitates the analysis.  To see this, we evaluate the contour integral $I(a,b)$, $ab\ne0$, given by
$$I(a,b)=\oint_C \frac{e^{iz}}{(z^2+a^2)(z^2+b^2)}\,dx\tag2$$
where $C$ is the closed contour comprised of $(i)$ the real line segment from $-R$ to $R$ and $(ii)$ the semi-circular arc centered at $z=0$ with radius $R$ from $R$ to $-R$.
We evaluate $(2)$ by application of the residue theorem.  Then, we let $R\to \infty$ and take the real part to find the value of $(1)$
$$\begin{align}\int_{-\infty}^\infty \frac{\cos(x)}{(x^2+a^2)(x^2+b^2)}\,dx&=\operatorname{Re}\left(2\pi i \operatorname{Res}\left(\frac{e^{iz}}{(z^2+a^2)(z^2+b^2)}, z=i|a|\right)\\+2\pi i \operatorname{Res}\left(\frac{e^{iz}}{(z^2+a^2)(z^2+b^2)}, z=i|b|\right)\right)
\end{align}$$
And the rest is left to the interested reader.
