Differentiate each of the following from first principle:

*x*^{2} *e ^{x }*

#### Solution

\[ \frac{d}{dx}\left( f(x) \right) = \lim_{h \to 0} \frac{f\left( x + h \right) - f\left( x \right)}{h}\]

\[\frac{d}{dx}\left( x^2 e^x \right) = \lim_{h \to 0} \frac{(x + h )^2 e^{(x + h)} - x^2 e^x}{h}\]

\[ = \lim_{h \to 0} \frac{( x^2 + 2xh + h^2 ) e^x e^h - x^2 e^x}{h}\]

\[ = \lim_{h \to 0} \frac{x^2 e^x e^h + 2xh e^x e^h + h^2 e^x e^h - x^2 e^x}{h}\]

\[ = \lim_{h \to 0} \frac{x^2 e^x e^h - x^2 e^x}{h} + \lim_{h \to 0} \frac{2 x h e^x e^h}{h} + \lim_{h \to 0} \frac{h^2 e^x e^h}{h}\]

\[ = \lim_{h \to 0} \frac{x^2 e^x \left( e^h - 1 \right)}{h} + \lim_{h \to 0} 2 x e^x e^h + \lim_{h \to 0} h e^x e^h \]

\[ = x^2 e^x \left( 1 \right) + 2x e^x \left( 1 \right) + 0\]

\[ = x^2 e^x + 2x e^x \]

\[ = \left( x^2 + 2x \right) e^x \]