Question:
Evaluate the following integrals:
$\int x^{2} e^{-x} d x$
Solution:
Let $I=\int x^{2} e^{-x} d x$
Using integration by parts,
$=x^{2} \int e^{-x} d x-\int \frac{d}{d x} x^{2} \int e^{-x} d x$
We know that, $\int e^{n x} d x=\frac{e^{x}}{n}$ and $\frac{d}{d x} x^{n}=n x^{n-1}$
$=x^{2} \times-e^{-x}-\int 2 x \times-e^{-x} d x$
Using integration by parts in second integral, $=-\mathrm{x}^{2} \mathrm{e}^{-\mathrm{x}}+2\left(\mathrm{x} \int \mathrm{e}^{-\mathrm{x}} \mathrm{dx}-\int \frac{\mathrm{d}}{\mathrm{dx}} \mathrm{x} \int \mathrm{e}^{-\mathrm{x}} \mathrm{dx}\right)$
$=-x^{2} e^{-x}+2\left(-x e^{-x}+\left(-e^{-x}\right)\right)+c$
$=-x^{2} e^{-x}+2\left(-x e^{-x}-e^{-x}\right)+c$
$I=-e^{-x}\left(x^{2}+2 x+2\right)+c$