Show that
Question:

$x^{2} e^{x}$

Solution:

Let $I=\int x^{2} e^{x} d x$

Taking $x^{2}$ as first function and $e^{x}$ as second function and integrating by parts, we obtain

\begin{aligned} I &=x^{2} \int e^{x} d x-\int\left\{\left(\frac{d}{d x} x^{2}\right) \int e^{x} d x\right\} d x \\ &=x^{2} e^{x}-\int 2 x \cdot e^{x} d x \\ &=x^{2} e^{x}-2 \int x \cdot e^{x} d x \end{aligned}

Again integrating by parts, we obtain

$=x^{2} e^{x}-2\left[x \cdot \int e^{x} d x-\int\left\{\left(\frac{d}{d x} x\right) \cdot \int e^{x} d x\right\} d x\right]$

$=x^{2} e^{x}-2\left[x e^{x}-\int e^{x} d x\right]$

$=x^{2} e^{x}-2\left[x e^{x}-e^{x}\right]$

$=x^{2} e^{x}-2 x e^{x}+2 e^{x}+\mathrm{C}$

$=e^{x}\left(x^{2}-2 x+2\right)+\mathrm{C}$