How to integrate $\int\frac{x}{(x^2-2x+5)^2} \, dx$? $$\int\frac{x}{(x^2-2x+5)^2} \, dx$$
I tried to complete the square of the bottom like this $\int\frac{x}{((x-1)^2+4)^2} \, dx$ but I'm still not sure what to do.
Any help would be appreciated.
Thanks
 A: The below solution is obtained from WolframAlpha.

A: The standard first calculus course substitution is $x-1=2\tan t$. Then $dx=2\sec^2 t$, and $(x-1)^2+4=4\sec^2 t$. So our integral is equal to
$$\int \frac{(1+2\tan t)(2\sec^2 t)}{16\sec^4 t}\,dt.$$
Separate into two parts in the natural way. The integral 
$$\int \frac{2}{16}\frac{1}{\sec^2 t}\, dt$$
is familiar, we need to integrate $\frac{2}{16}\cos^2 t$.
The remaining integral is 
$$\int \frac{4}{16}\frac{\tan t}{\sec^2 t}\,dt$$
is also done by switching to the more familiar sines and cosines. We end up needing
$$\int\frac{4}{16}\sin t\cos t\,dt.$$
This one is immediate: let $u=\sin t$. 
Remark: It may be worthwhile at the very beginning to  write the top as $(x-1)+1$. Then note that $x-1$ is almost the derivative of
$x^2-2x+5$, making the substitution $u=x^2-2x+5$ natural. So that's an easy integral.
Now all we need to do is to find the integral of $\dfrac{1}{(x^2-2x+5)^2}$.
Complete the square and make the substitution $x-1=2\tan t$ like in the main answer. 
A: A good strategy, now that you've completed the square is to also "complete the differential":
$$\int\frac{x}{((x-1)^2+4)^2} \, dx=$$
$$\frac 1 2\int\frac{2(x-1)}{((x-1)^2+4)^2} \, dx+\int\frac{1}{((x-1)^2+4)^2} \, dx=$$
$$\frac 1 2\int\frac{du}{u^2} +\int\frac{1}{(u^2+4)^2} \, du=$$
$$-\frac 1 2\frac{1}{u} +\int\frac{1}{(u^2+4)^2} \, du=$$
Now, to solve $$\int\frac{1}{(u^2+4)^2} \, du$$
take $2\tan \rho =u$
It will follow
$$\int\frac{1}{(u^2+4)^2} \, du$$
$$\int\frac{2\sec^2\rho }{16\sec^4 \rho } \,d\rho$$
$$\int\frac{1}{8\sec^2 \rho } \,d\rho=\frac 1 8\int{\cos^2\rho}  \,d\rho$$
Now use the fact that $\dfrac{1+\cos(2x)}{2}=\cos^2 x$ to finish it off.
