Integration using different substitutions resulting in different answers? I'm going through the MIT online calc course, and I'm trying to find the following from an Integration Problem set:
$$\int \frac{x^2+1}{x^2+2x+2}dx$$
I could use the substitution u = x+1, which results in the correct answer:
$$\int \frac{(u-1)^2+1}{u^2+1}du$$
$$\int 1 + \frac{1}{u^2+1} - \frac{2u}{u^2+1}du$$
$$u + arctan \; u - ln(u^2+1)$$
$$x+1+arctan \; (x+1) - ln(x^2+2x+2)$$
But originally I tried using completing the square and the substitution $(tan \theta = x + 1)$. I get:
$$\int \frac{x^2+1}{(x+1)^2+1}dx$$
$$\int \frac{tan^2 \theta - 2tan \theta + 1 + 1}{sec^2\theta}sec^2\theta d\theta$$
$$\int sec^2\theta - 2tan\theta+1 d\theta$$
$$tan \theta + 2ln(cos \theta) + \theta$$
$$x + 1 - 2ln(x^2+2x+2) + arctan(x+1)$$
There's an extra 2 coefficient there.  I don't think there's a math error, so I'm thinking the ambitious substitution is the cause.  Any ideas?

The mistake is in thinking $\cos\theta=x^2+2x+2$.
Remark: I would probably want to divide first, getting $1-\dfrac{2x+1}{(x+1)^2+1}$.
Then write $\dfrac{2x+1}{(x+1)^2+1}$ as $\dfrac{2x+2}{(x+1)^2+1}-\dfrac{1}{(x+1)^2+1}$.  
