# How do you differentiate f(x)=x-xe^(x-x^2/2) using the product rule?

Feb 25, 2018

See the explanation below.

#### Explanation:

Let $y = x - x {e}^{x - {x}^{2} / 2}$.

Factor out $x$.

$y = x \left(1 - {e}^{x - {x}^{2} / 2}\right)$

Take the derivative and use the $\textcolor{b l u e}{\text{product rule}}$ :

dy/dx = color(red)(d/dx(x))(1-e^(x-x^2/2)) + xcolor(red)(d/dx (1-e^(x-x^2))

The $1$ doesn't matter when differentiating.

Let $g \left(x\right) = {e}^{x - {x}^{2} / 2}$

Using the property that $\textcolor{b l u e}{\frac{d}{\mathrm{dx}} - f \left(x\right) = - \frac{d}{\mathrm{dx}} f \left(x\right)}$, we get :

dy/dx = 1-e^(x-x^2/2)-x*color(red)(g'(x)

We have to solve the for $\textcolor{red}{g ' \left(x\right)}$.

Take the natural logarithm of $g \left(x\right)$ :

$\ln \left(g \left(x\right)\right) = \left(x - {x}^{2} / 2\right) \ln e = x - {x}^{2} / 2$

And now differentiate both sides :

$\frac{g ' \left(x\right)}{g \left(x\right)} = \frac{d}{\mathrm{dx}} x - {x}^{2} / 2 = \frac{d}{\mathrm{dx}} x - \frac{d}{\mathrm{dx}} {x}^{2} / 2$

$\frac{g ' \left(x\right)}{g \left(x\right)} = 1 - x$

$g ' \left(x\right) = \left({e}^{x - {x}^{2} / 2}\right) \left(1 - x\right)$

Substitute it in the $\frac{\mathrm{dy}}{\mathrm{dx}}$ equation :

$\frac{\mathrm{dy}}{\mathrm{dx}} = 1 - {e}^{x - {x}^{2} / 2} - x \left({e}^{x - {x}^{2} / 2}\right) \left(1 - x\right)$, so
$\frac{\mathrm{dy}}{\mathrm{dx}} = 1 - {e}^{x - {x}^{2} / 2} \left(1 - x \left(1 - x\right)\right)$
$\frac{\mathrm{dy}}{\mathrm{dx}} = 1 - {e}^{x - {x}^{2} / 2} \left(1 - x + {x}^{2}\right)$
And finally,

color(blue)(f'(x) =1-e^(x-x^2/2)(x^2+x-1) .