# Evaluating an integral by parts.

Evaluate the following integral.

$$\int x^2 e^x\ dx$$

What i have tried :

$f^{'}(x) = e^x , f(x) = e^x , g(x) = x^2$

$$\int x^2 e^x\ dx = e^x\ x^2 - \int e^x\ 2x\ dx$$

$f^{'}(x) = e^x , f(x) = e^x , g(x) = 2x$

$$\int x^2 e^x\ dx = e^x\ x^2 - e^x\ 2x - \int e^x\ x\ dx$$

$f^{'}(x) = e^x , f(x) = e^x , g(x) = x$

$$\int x^2 e^x\ dx = e^x\ x^2 - e^x\ 2x - x\ e^x - \int e^x \ dx$$

$$\int x^2 e^x\ dx = e^x\ x^2 - e^x\ 2x - x\ e^x - e^x + C$$

The answer in the book is $x^2e^x-2xe^x+2e^x+C$

What did i do wrong ?

• Note that integration by parts is essentially the product rule for differentiation in integral form. $\frac d{dx} x^2e^x = 2xe^x+x^2e^x$, and $\frac d{dx} xe^x=e^x+xe^x$. Integrate these two expressions with respect to $x$ and you will see what I mean. Feb 9 '14 at 19:28

$$\int x^2 e^x\ dx = e^x\ x^2 - e^x\ 2x - \int e^x\ x\ dx$$
$$\int x^2 e^x\ dx = e^x\ x^2 -\Big(e^x\ 2x - \int 2e^x\, dx\Big)$$
Then, integrating on the right gives and distributing the negative gives us $$x^2e^x - 2xe^x + 2e^x$$