Evaluate the improper integral. Evaluate the integral below. 
$ \int^{+\infty}_{-\infty} \frac{x^2}{{(x^2-8x+20)}^2} \, dx $
I feel that I know how to do this problem, but I'm getting caught up in all the calculations. I've been approaching the problem the way we were taught in class. This is what I've done so far: 
1) I rewrote it as $\lim_{\to\infty}  \int^{A}_{-A} \frac{x^2}{{(x^2-8x+20)}^2} \, dx$ 
2) In order to use the Residue Theorem we must be integrating over a closed contour. I picked a semi-circle centered at the origin in the upper half plane.  From here I started to find the singularities so that I could compute the residues. 
From what I understand, the singularities are the zeros of the denominator in a rational function.  I came up with -2 and 10. 10 is in the domain that I chose. 
So from here prior to computing the residues, we've been told to break the integral into two pieces... honestly this is where I get confused. Can someone help me continue? 

I'm still feeling a little confused and I'm hoping to see the solution to this problem done out so that I can see where I'm going wrong. As many of you noticed I calculated the singularities incorrectly the first time. I now have 2i+4 as the singularity that is in the semi circle centered at the origin in the upper half plane if A >4. 
Can someone please offer a solution to the conclusion of this problem? 
 A: You can actually do this one on the real line by ordinary integration.
Let $x = u+4$, then you are finding
$$
\int_{-\infty}^\infty \frac{u^2}{(u^2+4)^2} du + 8 \int_{-\infty}^\infty \frac{u}{(u^2+4)^2} du +16 \int_{-\infty}^\infty \frac{1}{(u^2+4)^2} du 
$$
The middle term is zero since each $\int_{-a}^a$  is an integral of an odd function over an interval symmetric about zero, hences is zero.
IBP on the first term gives the indefinite integral 
$$
\int \frac{u^2}{(u^2+4)^2} du = -\frac{u}{2(u^2+4)^2} + \frac12 \int \frac{du}{u^2+4}
$$
IBP on the last term gives the indefinite integral 
$$
\int \frac{1}{(u^2+4)^2} du = \frac{u}{8(4+u^2)} + \frac{1}{8} \int \frac{du}{u^2+4}
$$
Combining, with the coefficient of $16$ above, this gives us 
$$  -\frac{u}{2(u^2+4)^2} + \frac12 \int \frac{du}{u^2+4} + \frac{2u}{4+u^2} +2\int \frac{du}{u^2+4} \\
=  \frac{2u}{4+u^2} -\frac{u}{2(u^2+4)^2} +\frac52\int \frac{du}{u^2+4}
$$
Of these, only the term with the integral survives as $|u|\to \infty$. Then 
$$
\frac52\int \frac{du}{u^2+4} =
\left. \frac52 \frac12 \tan^{-1} u \right|_{-\infty}^\infty = \frac54 \pi
$$
I must admit the $\frac54$ was unexpected so you should check the work, but the point is that this is an integral where the indefinite integral is expressible in terms of elementary functions.
A: If you want to use the residue theorem, then be careful.  The two poles (at $z=4\pm i2$) are of second order (since the quadratic term is squared).  
You can still close the contour in the upper-half plane.  Thus, 
$$\int_{-\infty}^{\infty}\frac{x^2}{(x^2-8x+20)^2}dx=2\pi i \,\text{Res}_{z=4+2i}\left(\frac{z^2}{(z^2-8z+20)^2}\right)$$
For a pole of order $n$ the residue of $f$ at $z_0$ is given by
$$\frac{1}{(n-1)!}\lim_{z\to z_0}\frac{d^{n-1}}{dz^{n-1}}\left((z-z_0)^nf(z)\right)$$
Here, we have $n=2$, $z_0=4+2i$, and $f(z)=\frac{z^2}{(z-(4+2i))^2(z-(4-2i))^2}$.  Thus
$$\text{Res}_{z=4+2i}\left(\frac{z^2}{(z^2-8z+20)^2}\right)=\frac{2(4+2i)}{(4i)^2}-\frac{2(4+2i)^2}{(4i)^3}=-\frac58 i$$
Thus, after multiplying by $2\pi i$, we find 
$$\int_{-\infty}^{\infty}\frac{x^2}{(x^2-8x+20)^2}dx=5\pi/4$$
A: Using partial fraction decomposition,
$$
\frac{z^2}{(z^2-8z+20)^2}=\frac{-\frac34-i}{(z-4-2i)^2}+\frac{-\frac34+i}{(z-4+2i)^2}+\color{#C00000}{\frac{-\frac58i}{z-4-2i}}+\frac{\frac58i}{z-4+2i}
$$
and the limit of the contour as $R\to\infty$
$$
\gamma=[-R,R]\cup Re^{i[0,\pi]}
$$
we have that the singularity inside $\gamma$ is $z=4+2i$, which has residue $-\frac58i$. Therefore,
$$
\int_\gamma\frac{z^2}{(z^2-8z+20)^2}\,\mathrm{d}z=2\pi i(-\tfrac58i)=\frac54\pi
$$
