Yep, you’ll need integration by parts! Two rounds of it. Lucky you :P
Start by choosing one term to be u and one term to be dv. You’ll have to take the derivative of u and integrate dv. The important thing is to always choose u to be something that gets simpler when you take the derivative. e^x remains e^x when you derive, so don’t choose that.
u = (x-x^2), dv = e^x
du = 1–2x, v = e^x
Now your formula is:
integral(udv) = uv – integral(vdu)
So integral((x-x^2)e^x) = (x-x^2)e^x – integral((1–2x)e^x)
But in order to solve that second integral, (1–2x)e^x, you have to use integration by parts again!
Choose u = 1–2x, dv = e^x
du = -2, v = e^x
integral((1–2x)e^x) = (1–2x)e^x – integral(-2e^x)
Okay, NOW the integral on the righthand side is easily solvable! In fact its integral is itself: -2e^x.
Plug THAT in to the first result from integration by parts:
integral((x-x^2)e^x) = (x-x^2)e^x – integral((1–2x)e^x)
= (x-x^2)e^x – ((1–2x)e^x – integral(-2e^x))
= (x-x^2)e^x – ((1–2x)e^x – (-2e^x))
Now just distribute your negative signs:
= (x-x^2)e^x – (1–2x)e^x – 2e^x
You could leave it there, or clean it up a bit by distributing your terms and combining like terms:
xe^x – x^2e^x – e^x + 2xe^x – 2e^x
-x^2e^x + 3xe^x -3e^x
Done!