<s>[INST] How can I solve this integral using complex anlysis? $$\int_0^{\infty} \frac{\cos x }{(x^2+a^2)^2(x^2+b^2)}dx$$
I've tried changing $\cos x$ with $e^{iz}$ and $(x^2+a^2)^2(x^2+b^2)$ with $(z^2+a^2)^2(z^2+b^2)$ giving the integral $$\oint_\gamma \frac{e^{iz} }{(z^2+a^2)^2(z^2+b^2)}dz$$ over some contour and using partial fractions, but I did not get results.
I'm having problems finding the contour.
Some advices will be helpful.Thanks
 [/INST] By parity of the integrand function (and its integrability)
$$ \int_{0}^{+\infty}\frac{\cos x}{(x^2+a^2)^2(x^2+b^2)}\,dx = \frac{1}{2}\,\text{Re}\int_{-\infty}^{+\infty}\frac{e^{ix}\,dx}{(x^2+a^2)^2 (x^2+b^2)} $$
equals, by the ML lemma and the residue Theorem,
$$ \frac{1}{2} \text{Re}\lim_{R\to +\infty}\oint\frac{e^{iz}\,dz}{(z^2+a^2)^2 (z^2+b^2)}= -\pi\text{ Im}\!\!\!\!\sum_{z_0\in\{ia,ib\}}\!\!\!\text{Res}\left(\frac{e^{iz}}{(z^2+a^2)^2 (z^2+b^2)},z=z_0 \right) $$
(assuming $a,b\in\mathbb{R}^+$ and $a\neq b$). A simple approach might be to recognize that by partial fraction decomposition the given integral only depends on the parametric integrals
$$ I_1(A) = \int_{0}^{+\infty}\frac{\cos x}{x^2+A}\,dx,\qquad I_2(A) = \int_{0}^{+\infty}\frac{\cos x}{(x^2+A)^2} $$
defined for $A\in\mathbb{R}^+$. We have $I_1(A)=\frac{\pi}{2\sqrt{A}}e^{-\sqrt{A}}$ and $I_2(A) = -\frac{d}{dA} I_1(A)$, from which it follows that $I_2(A)=\frac{\pi}{4A\sqrt{A}}(1+\sqrt{A})\,e^{-\sqrt{A}}$. Now it is enough to consider the cases $A=a^2$, $A=b^2$ and combine them to get the value of the original integral.
</s>