# How do you find the 1st and 2nd derivative of y=x^2e^x-4xe^x+2e^x?

Oct 20, 2016

$\frac{\mathrm{dy}}{\mathrm{dx}} = {e}^{x} \left({x}^{2} - 2 x - 2\right)$ or ${x}^{2} {e}^{x} - 2 x {e}^{x} - 2 {e}^{x}$
$\therefore \frac{{d}^{2} y}{\mathrm{dx}} ^ 2 = {e}^{x} \left({x}^{2} - 4\right)$ or ${x}^{2} {e}^{x} - 4 {e}^{x}$

#### Explanation:

Use the product rule: $\frac{d}{\mathrm{dx}} u v = u \frac{\mathrm{dv}}{\mathrm{dx}} + v \frac{\mathrm{du}}{\mathrm{dx}}$

So $y = {x}^{2} {e}^{x} - 4 x {e}^{x} + 2 {e}^{x}$
$\therefore y = \left({x}^{2} - 4 x + 2\right) {e}^{x}$

The product rule gives:

$\frac{\mathrm{dy}}{\mathrm{dx}} = \left({x}^{2} - 4 x + 2\right) \frac{d}{\mathrm{dx}} {e}^{x} + {e}^{x} \frac{d}{\mathrm{dx}} \left({x}^{2} - 4 x + 2\right)$
$\therefore \frac{\mathrm{dy}}{\mathrm{dx}} = \left({x}^{2} - 4 x + 2\right) {e}^{x} + {e}^{x} \left(2 x - 4\right)$
$\therefore \frac{\mathrm{dy}}{\mathrm{dx}} = {e}^{x} \left({x}^{2} - 4 x + 2 + 2 x - 4\right)$
$\therefore \frac{\mathrm{dy}}{\mathrm{dx}} = {e}^{x} \left({x}^{2} - 2 x - 2\right)$

Applying the product rule again:
$\frac{{d}^{2} y}{\mathrm{dx}} ^ 2 = \left({x}^{2} - 2 x - 2\right) \frac{d}{\mathrm{dx}} {e}^{x} + {e}^{x} \frac{d}{\mathrm{dx}} \left({x}^{2} - 2 x - 2\right)$
$\therefore \frac{{d}^{2} y}{\mathrm{dx}} ^ 2 = \left({x}^{2} - 2 x - 2\right) {e}^{x} + {e}^{x} \left(2 x - 2\right)$
$\therefore \frac{{d}^{2} y}{\mathrm{dx}} ^ 2 = {e}^{x} \left({x}^{2} - 2 x - 2 + 2 x - 2\right)$
$\therefore \frac{{d}^{2} y}{\mathrm{dx}} ^ 2 = {e}^{x} \left({x}^{2} - 4\right)$