Why integration by long division gives different answer than using u substitution? So, after solving this question, I got two different answers? and I don't think it's supposed to be this way?


  Evaluate the integral $$\int \frac{x^2+2}{x+2} dx$$


Using polynomial long division, I get
$$\frac{x^2}2-2x+6\ln|x+2|+C,$$
but using substitution, I get
$$\frac{(x+2)^2}2-4(x+2)+6\ln|x+2|+C.$$
Note that 

$$\frac{(x+2)^2}2-4(x+2)+6\ln|x+2|+C=\frac{x^2}2-2x-6+6\ln|x+2|+C=$$

$$=\frac{x^2}2-2x+6\ln|x+2|+(C-6)=\frac{x^2}2-2x+6\ln|x+2|+C_1$$

therefore the two results are the same up to a constant which is not essential, indeed in both cases

$$\frac{d}{dx}\left(\frac{x^2}2-2x+6\ln|x+2|+C\right)=\frac{x^2+2}{x+2}$$
Your answers differ by a constant. Therefore, if one of them is correct, the other one is correct too.