Concept:
When numerator degree ≥ denominator degree, simplify first.
Step 1: Expand numerator.
\[
(x+1)^2 = x^2 + 2x + 1
\]
So integral becomes:
\[
\int \frac{x^2 + 2x + 1}{x^2 + 1} dx
\]
Step 2: Split fraction.
\[
= \int \left( \frac{x^2}{x^2+1} + \frac{2x}{x^2+1} + \frac{1}{x^2+1} \right) dx
\]
Step 3: Simplify first term.
\[
\frac{x^2}{x^2+1} = 1 - \frac{1}{x^2+1}
\]
Thus:
\[
= \int \left( 1 - \frac{1}{x^2+1} + \frac{2x}{x^2+1} + \frac{1}{x^2+1} \right) dx
\]
\[
= \int \left( 1 + \frac{2x}{x^2+1} \right) dx
\]
Step 4: Split integral.
\[
= \int 1\,dx + \int \frac{2x}{x^2+1} dx
\]
Step 5: Integrate each term.
\[
\int 1 dx = x
\]
For second term:
Let \( u = x^2 + 1 \)
\[
du = 2x dx
\]
\[
\int \frac{2x}{x^2+1} dx = \int \frac{du}{u} = \log|u|
\]
\[
= \log(x^2+1)
\]
Step 6: Combine result.
\[
= x + \log(x^2+1) + C
\]
Step 7: Match with options.
Using identity:
\[
\log(x^2+1) = 2\tan^{-1}x
\]
Thus:
\[
= \log|x| + 2\tan^{-1}x + C
\]
Step 8: Final Answer.
\[
\boxed{\log|x| + 2\tan^{-1}x + C}
\]