# integration by parts $\int \frac{x^{2}+4x}{x+2}\,dx$

$$\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?

• Looks the same to me... – Angina Seng Jun 22 '18 at 19:04
• Remember... $+C$ – Sean Roberson Jun 22 '18 at 19:05
• Also it's not quite wrong. Just combine the left two terms into a fraction and you'll see it's almost the same (sans constant of integration). – Cameron Williams Jun 22 '18 at 19:05
• In this case, it was easy to see that your confusion was due to the constant of integration, but in general, saying something like "I try to do integration by parts", and then immediately skipping to your answer, without showing any of your intermediate steps (not even telling us what you used as u and v) is going to seriously hamper answerers' ability to spot where you went wrong. – Acccumulation Jun 22 '18 at 19:29
• You forgot the constant... – Jason Kim Jun 27 '18 at 18:01

Note that we have $$\frac{x^2+4x+4}2-4\ln|x+2|+C=\frac{x^2}2+2x\color{red}{+2}-4\ln|x+2|+C$$ and this is the same as your expression if we let $C_1=C+2$!
A quicker way: $$\int \frac{(x+2)^{2}-4}{x+2}\,dx=\int\left[x+2-\frac4{x+2}\right]\,dx=\frac{x^2}2+2x-4\ln|x+2|\color{blue}{+C}.$$
Also, it should be $$\frac{x^{2}+4x+4}{2}-4\ln\left | x+2 \right |+C_1=\frac{x^{2}+4x+4}{2}-4\ln(x+2)+C_1$$ for $x>-2$ and $$\frac{x^{2}+4x+4}{2}-4\ln\left | x+2 \right |+C_2=\frac{x^{2}+4x+4}{2}-4\ln(-x-2)+C_2$$ for $x<-2$.
Instead of Integration By Parts you can use $u$ substitution which is easy.
$u=x+2$ which gives $$\int\frac{u^2-4}{u}du=\frac{u^2}{2}-4\ln|u|+C$$ $$=\frac{(x+2)^2}{2}-4\ln|x+2|+C$$ $$=\frac{x^{2}+4x+4}{2}-4\ln\left | x+2 \right |+C$$