I’m attempting to integrate the expression $\frac{x^2+x+1}{x^2+1}$ with respect to $x$. I divided the numerator into the denominator and proceeded as: $\int\left(1+\frac{x}{x^2+1}\right)dx=\int dx + \frac12\int\frac{2x}{x^2+1}dx=x+\frac12\ln\left(x^2+1\right)+C$. My book confirms this is the correct answer.
However, it occurred to me that, rather than appealing to substitution, I could divide again, instead proceeding as follows:
$\int dx + \int x+\frac1xdx = x + \frac{x^2}{2}+\ln(x)+C$.
Assuming I did my math correctly, and I can’t see anything wrong with what I did, how are these two expressions equivalent to one another? Obviously the $x+C$ in both expressions will cancel out, but how do I show that $\frac12\ln\left(x^2+1\right)=\frac{x^2}2+\ln(x)$?
Your division went upside down when you had $$\frac {x}{x^2+1} \overset{?}{=} x+1/x$$
You did the integration correct in $$\int dx + \int x+\frac1xdx = x + \frac{x^2}{2}+\ln(x)+C$$
but the mistake in dividing made your answer different from the correct one.