$$\int \ln(x^2 +1)\ dx$$
I done it using integration by parts where
$\int u\ dv = uv - \int v\ du$
Let $u$ = $\ln(x^2 +1)$
$du = \frac{2x}{x^2+1} dx $
Let $dv = dx$ so $v=x$
$\int \ln(x^2 +1)\ dx = x \ln (x^2 +1) - \int \frac{2x^2}{x^2+1} $
I integrate $2\int \frac{x^2}{x^2+1} $ separately using substitution.
Let $u$ = $x^2 + 1$ -> $dx= \frac{1}{2x} du $
substitute $u$ back into it I get a simplified $\int \frac{x}{x^2 + 1} dx$
I used substitution again and got $ \frac{1}{2} \int \frac{1}{u} du$
When I sub it back into the original question, this is my final answer,
$x\ln(x^2 +1) + \frac{1}{2} \ln(x^2 +1) + C$
However, this answer is wrong,
The answer is, $x\ln(x^2 +1) - 2x + 2\tan^{-1} (x) + C $
I believe my integration of $2\int \frac{x^2}{x^2+1} $ is wrong. Where did I went wrong ?