Integrate $\frac{x^2+1}{(x^2-2x+2)^2}$ using trigonometric substitutions I've attempted to integrate the function $\frac{x^2+1}{(x^2-2x+2)^2}$ using several techniques, but none of them are solving it nicely.
I know there must be a way to do this using trig substitution (its from that chapter of my text book), just not sure how to do it..
I've tried substituting and simplifying till:
$$\frac{(1+u)^2+1}{(1+u^2)^2}$$
Then subbing $1+u^2$ for $\sec^2(u)$ but still no luck. Anything I'm missing?
I think it might be possible to rewrite the initial function to have a $\sqrt{\cdot}$ as the denominator but not sure how to work that out...
 A: Here is the trigonometric approach
$$ \int \frac{x^2+1}{(x^2-2x+2)^2}dx = \int \frac{x^2+1}{((x-1)^2+1)^2}dx = \int\frac{(1+u)^2+1}{(u^2+1)^2}du .$$
Using the substitution $u=\tan(y)$ gives
$$ \int \!{\frac {  \tan\left( y \right)^{2}+2\,\tan
 \left( y \right) +2}{ (1+\tan\left(y\right)^{2})^2 }}{dy}$$
$$ = 2\int(\sin \left( y \right) \cos \left( y \right) +  \cos
 \left( y \right)^{2}+1)\,{dy} =\dots $$
Notes:
$$ (1)\,\, 1+\tan(y)^2=\sec(y)^2,  $$
$$ (2)\,\, \cos(2y) = 2\cos(y)^2 - 1. $$ 
A: As a first step one can use partial fractions to express our integrand as $$\frac{A+Bu}{1+u^2}+\frac{C+Du}{(1+u^2)^2}.$$
Then the $Bu$ and $Cu$ yield to a simple substitution, and for the $A$ part we will get an arctan. It remains to integrate $\frac{C}{(1+u^2)^2}$. This can be done by a trigonometric substitution, or by using integration by parts. 
The trigonometric substitution is the obvious $u=\tan\theta$. We then end up integrating $\cos^2\theta$. I somewhat prefer parts. The idea is to attempt to integrate $\frac{1}{1+u^2}$ (yes) by parts, letting $dv=du$ and $w=\frac{1}{1+u^2}$.
Another way: The first solution was generic, and intended to show that there is a general algorithmic procedure for such problems. 
We can do it with much less machinery. The numerator is $1+u^2 +2u+1$. When we divide by $(1+u^2)^2$, we get
$$\frac{1}{1+u^2}+\frac{2u}{1+u^2} +\frac{1}{(1+u^2)^2}.$$
Integrate. The first term gives $\arctan u$. The second, possibly after letting $1+u^2=v$, gives $\ln(1+u^2)$.
It remains to deal with the third term. Let $u=\tan t$. After the smoke clears, we want $\int \cos^2 t\,dt$, which is a standard integral. 
