TITLE: Evaluate a real integral, e.g. $\int_{0}^{\infty}\frac{x^2}{(x^2+1)(x^2+4)}\:\mathrm dx$ with complex analysis
QUESTION [5 upvotes]: My question is more theoretical, i.e, i cannot quiet understand the "method" itself.
For example $$\int_{0}^{\infty}\frac{x^2}{(x^2+1)(x^2+4)}\:dx$$ 
I know that the fact of the denominator having no real roots and that $deg((x^2+1)(x^2+4))-deg(x^2)\geq2$ are "important informations" but i dont how to apply them. Can someone help me? I know that we are supposed to apply the residue Theorem after, but i cannot understand the steps in order to apply it.
Thank you!

REPLY [3 votes]: Define $f:\mathbb{C}\mapsto\mathbb{C}$ by
$$f(z)=\frac{z^2}{(z^2+1)(z^2+4)}=\frac{z^2}{(z+i)(z-i)(z+2i)(z-2i)}$$
Then we want to calculate
$$\int_0^\infty f(z)\mathrm{d}z=\frac12\int_{-\infty}^\infty f(z)\mathrm{d}z$$where the latter equality holds as $f$ is even. Now consider the semi-circular contour, $C$, containing the real interval $(-R,R)$ and passing through $Ri$ on the imaginary axis. The contour integral of $f(z)$ over $C$ can be found easily for $R\gt2$ by applying Cauchy's residue theorem. We get
$$\oint_Cf(z)\mathrm{d}z=2\pi i\cdot (\text{Res}(f,i)+\text{Res}(f,2i))=\frac{\pi}3$$Now taking $R\to\infty$ the contour integral of $f(z)$ over the arc of the semi-circular contour tends to zero so we get
$$\int_0^\infty f(z)\mathrm{d}z=\frac12\cdot\frac{\pi}3=\frac{\pi}6$$