# How do you differentiate f(x)=-2e^(x^2cosx  using the chain rule?

#### Answer:

$\frac{\mathrm{dy}}{\mathrm{dx}} = 2 x {e}^{{x}^{2} \cos x} \left(x \sin x - 2 \cos x\right)$

#### Explanation:

$f \left(x\right) = - 2 {e}^{{x}^{2} \cos x}$
Let
$y = f \left(x\right)$
Then
$y = - 2 {e}^{{x}^{2} \cos x}$
Let
$u = {e}^{{x}^{2} \cos x}$
Taking logarithms
$\ln u = {x}^{2} \cos x$
Differentiating wrt x
$\frac{1}{u} \frac{\mathrm{du}}{\mathrm{dx}} = {x}^{2} \left(- \sin x\right) + \cos x \left(2 x\right)$
$\frac{1}{u} \frac{\mathrm{du}}{\mathrm{dx}} = - {x}^{2} \sin x + 2 x \cos x$
$\frac{\mathrm{du}}{\mathrm{dx}} = u \left(- {x}^{2} \sin x + 2 x \cos x\right)$
$y = - 2 {e}^{{x}^{2} \cos x}$
$y = - 2 u$
Differentiating
$\frac{\mathrm{dy}}{\mathrm{dx}} = - 2 \frac{\mathrm{du}}{\mathrm{dx}}$
$\frac{\mathrm{du}}{\mathrm{dx}} = u \left(- {x}^{2} \sin x + 2 x \cos x\right)$
$\frac{\mathrm{dy}}{\mathrm{dx}} = - 2 \left(u \left(- {x}^{2} \sin x + 2 x \cos x\right)\right)$
$\frac{\mathrm{dy}}{\mathrm{dx}} = 2 u \left({x}^{2} \sin x - 2 x \cos x\right)$
$u = {e}^{{x}^{2} \cos x}$
$\frac{\mathrm{dy}}{\mathrm{dx}} = 2 {e}^{{x}^{2} \cos x} \left({x}^{2} \sin x - 2 x \cos x\right)$
$\frac{\mathrm{dy}}{\mathrm{dx}} = 2 x {e}^{{x}^{2} \cos x} \left(x \sin x - 2 \cos x\right)$