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!
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.