Let $I = \int x^{2} e^{x} dx$.
Using the integration by parts formula,$\int u v dx = u \int v dx - \int (u' \int v dx) dx$.
Taking $u = x^{2}$ and $v = e^{x}$,we get:
$I = x^{2} \int e^{x} dx - \int (\frac{d}{dx} x^{2} \cdot \int e^{x} dx) dx$
$I = x^{2} e^{x} - \int 2x e^{x} dx$
$I = x^{2} e^{x} - 2 \int x e^{x} dx$.
Applying integration by parts again for $\int x e^{x} dx$ with $u = x$ and $v = e^{x}$:
$\int x e^{x} dx = x e^{x} - \int (1 \cdot e^{x}) dx = x e^{x} - e^{x}$.
Substituting this back into the expression for $I$:
$I = x^{2} e^{x} - 2(x e^{x} - e^{x}) + C$
$I = x^{2} e^{x} - 2x e^{x} + 2e^{x} + C$
$I = e^{x}(x^{2} - 2x + 2) + C$,where $C$ is an arbitrary constant.