Evaluating an improper integral using the Residue Theorem I have:
\begin{equation}
\int_{-\infty}^{\infty}\frac{x^2}{(x^2+1)(x^2+9)}dx
\end{equation}
and I want to solve it using a complex closed contour on C. I do the following:
\begin{equation}
\int_{-\infty}^{\infty}\frac{z^2}{(z^2+1)(z^2+9)}dz
\end{equation}
which clearly has 4 poles, $\pm i,\pm3i $. The greatest radius of the clontour is thus $\rho=3$, therefore I get the following integral form:
\begin{equation}  
\int_{\gamma_3}\frac{z^2}{(z^2+1)(z^2+9)}dz=2\pi i Res(f;i,+3i)
\end{equation}
which gives for i:
\begin{equation}
Res(i)=\lim_{z\longrightarrow i}(z-i)\frac{z^2}{(z-i)(z+i)(z+3i)(z-3i)}dz=i/16
\end{equation}
and for 3i:
\begin{equation}
Res(3i)=\lim_{z\longrightarrow 3i}(z-3i)\frac{z^2}{(z-i)(z+i)(z+3i)(z-3i)}dz=-i/48
\end{equation}
Plugging into the formula given above, I get:
\begin{equation}  
\int_{\gamma_3}\frac{z^2}{(z^2+1)(z^2+9)}dz=2\pi i (i/16-i/48)=-\frac{\pi}{12}
\end{equation}
But this is not correct, as the integral is negative.  Where is the error?
Thanks!

Also, using Calculus
$$
\frac{x^2}{(x^2+1)(x^2+9)}=\frac{1}{8}\left(\frac{9}{x^2+9}-\frac{1}{x^2+1}\right)
$$
and
$$
\int_{-\infty}^\infty\frac{dx}{x^2+1}=\tan^{-1}(x)\Big|_{x=-\infty}^{x=\infty}=\pi, \qquad
\int_{-\infty}^\infty\frac{dx}{x^2+9}=\frac{1}{3}\tan^{-1}(x/3)\Big|_{x=-\infty}^{x=\infty}=\frac{\pi}{3},
$$
and hence
$$
\int_{-\infty}^\infty\frac{x^2}{(x^2+1)(x^2+9)}=\frac{\pi}{4}.
$$
