$$\int \frac{x^{2}+4x}{x+2}\,dx$$
I have written it in this form:
$$\int \frac{(x+2)^{2}-4}{x+2}\,dx$$: on this stage I try to do integration by parts, which gets me to :
$$\frac{x^{2}}{2}+2x-4\ln\left | {x+2} \right |$$
but it's wrong for some reason. The right answer is : $$\frac{x^{2}+4x+4}{2}-4\ln\left | x+2 \right |$$
Where am I wrong?
You forgot the constant of integration. Your answer differs from the one given by a constant.