# Integration by parts - wondering what I did wrong

Looking for help in solving a certain integral by parts:

$$\int x^2 e^{-x} \, dx$$

What I did was:

$$u = x^2 \text{ and } dv = e^{-x} \, dx$$

along with

$du=2x \, dx$ and $v = -e^{-x}$

The integral then would be $\int x^2 e^{-x} \, dx = -x^2e^{-x} - \int -2xe^{-x} \, dx$

I simplified it to $-x^2e^{-x} - x^2e^{-x} + C$

My final answer was $-2^2e^{-x} +C$

and the book's answer is $-(x^2 + 2x + 2)e^{-x} + C$

I'm not entirely sure what I did wrong, hopefully somebody can point it out to me!

• How do you get your final answer? – user251257 Sep 29 '15 at 2:32
• Question edited to show work - I just simplified it a bit – bankey Sep 29 '15 at 2:32
• You need to integrate by parts a second time. Where you said "I simplified it to....", it's not at all clear how you got rid of the integral sign. ${}\qquad{}$ – Michael Hardy Sep 29 '15 at 3:25

## 1 Answer

You already have $$\int x^2e^{-x}dx = -x^2e^{-x} + 2\int xe^{-x}dx.$$

Now, you can continue $$\int xe^{-x}dx = -xe^{-x} + \int e^{-x}dx = -xe^{-x} - e^{-x}.$$

From this, you can get the final answer.

• So do I need to integrate by parts a second time? How do you go about figuring out when you need to do it a second or third time?? – bankey Sep 29 '15 at 2:35
• Yes, you should. It depends what you want. – GAVD Sep 29 '15 at 2:41
• Is there a way of knowing when you should continue integrating by parts? – bankey Sep 29 '15 at 2:42
• It is a difficult question. Sometimes, you will fall in the infinitive loop of intergrating. :) – GAVD Sep 29 '15 at 2:44
• Let $u = x$ and $v = -e^{-x}$, then you have $du = dx$ and $dv = e^{-x}dx$. From this, you can get that equation. – GAVD Sep 29 '15 at 2:49