Showing $\int_{0}^{\infty} \frac{1}{(x^2+1)^2(x^2+4)}=\frac{\pi}{18}$ via contour integration I want to show that:
$$\int_{0}^{\infty} \frac{1}{(x^2+1)^2(x^2+4)}=\frac{\pi}{18}$$ 
so considering:
$$\int_{\gamma} \frac{1}{(z^2+1)^2(z^2+4)}$$ where gamma is the curve going from $0$ to $-R$ along the real axis, from $-R$ to R via a semi-circle in the upper plane and then from $R$ to 0 along the real axis.
Using the residue theorem we have that:
$$\int_{\gamma} \frac{1}{(z^2+1)^2(z^2+4)}=2\pi i \sum Res$$
so re-writing the integrand as $\displaystyle\frac{1}{(z-2i)(z+2i)(z+i)^2(z-i)^2}$ 
we can see that there is two simple poles at $2i$,$-2i$ and two poles of order 2 at $i$,$-i$. 
Calculating the residues:
$$Res_{z=2i}=\lim_{z\rightarrow 2i} \displaystyle\frac{1}{(z+2i)(z+i)^2(z-i)^2}=\frac{1}{36i}$$
$$Res_{z=-2i}=\lim_{z\rightarrow 2i} \displaystyle\frac{1}{(z-2i)(z+i)^2(z-i)^2}=\frac{-1}{36i}$$
$$Res_{z=i}\lim_{z\rightarrow i} \frac{d}{dz} \frac{1}{(z-2i)(z+2i)(z+i)^2}=\frac{2i}{36}+\frac{2}{24i}$$
$$Res_{z=-i}\lim_{z\rightarrow -i} \frac{d}{dz} \frac{1}{(z-2i)(z+2i)(z-i)^2}=\frac{-2i}{36}+\frac{-2}{24i}$$
But now the sum of the residues is 0 and so when I integrate over my curve letting R go to $\infty$ (and the integral over top semi-circle goes to 0) I will just get 0?
Not sure what I've done wrong?
Thanks very much for any help
 A: Consider the contour $C$ that spans along $-R$ to $R$ and around the arc $Re^{i\theta}$ for $0\le\theta\le \pi$.  
Letting
$$f(z):=\frac{1}{(z^2+1)^2(z^2+4)}=\frac{1}{(z+i)^2(z-i)^2(z+2i)(z-2i)}$$
and we see the poles are located at $\pm i$ and $\pm 2i$.  Letting $R \to \infty$, it is very clear that the denominator explodes, causing the integral around the arc to disappear.  Then
$$\oint_C f(z)\, dz = 2\pi i(\operatorname*{Res}_{z = i}f(z) + \operatorname*{Res}_{z = 2i}f(z))$$
because $2i$ and $i$ are the only poles in $C$.
The pole of $i$ is of order 2:
$$
\operatorname*{Res}_{z = i}f(z) = 
\lim_{z \to i} \frac{1}{1!}\frac{d}{dz} (z-i)^2 f(z)= 
\lim_{z \to i} \frac{d}{dz}\frac{1}{(z+i)^2(z^2+4)}=
\lim_{z \to i} \frac{2(2z^2 +iz+4)}{(i+z)^3(4+z^2)^2}=-\frac{i}{36}
$$
The pole of $2i$ is simple:
$$
\operatorname*{Res}_{z = 2i}f(z) = 
\lim_{z \to 2i} (z-2i)f(z) = \frac{1}{(-4+1)^2(2i+2i)}=-\frac{i}{36}
$$
So finally 
$$
\int_0^\infty f(x)\, dx = \frac{1}{2}\int_{-\infty}^\infty f(x)\, dx = \pi i\left(-\frac{i}{36}-\frac{i}{36}\right) = \frac{\pi}{18}
$$
A: When using the residue theorem, you only consider residues enclosed by the path you are integrating over. In your case, you only consider residues in the upper half plane, as any point in the upper half plane will be enclosed by the semicircle as $R$ goes to infinity. Only $2i$ and $i$ lie in the upper half plane, out of the four poles of the function, so you only consider residues at those points. Your error comes from summing all of the residues, even ones that don't lie in the region bounded by the contour of integration.
