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

Mar 22, 2018

$f ' \left(x\right) = {x}^{2} \sin x - 3 {x}^{2} - 2 x \cos x + {e}^{x} \left(\sin x - \cos x - 1 - x\right)$

#### Explanation:

The product rule states that
$\frac{d}{\mathrm{dx}} \left(a b\right) = b \frac{\mathrm{da}}{\mathrm{dx}} + a \frac{\mathrm{db}}{\mathrm{dx}}$
Therefore,
$f ' \left(x\right) = \left(- {x}^{2} - {e}^{x}\right) \frac{d}{\mathrm{dx}} \left(\cos x + x\right) + \left(\cos x + x\right) \frac{d}{\mathrm{dx}} \left(- {x}^{2} - {e}^{x}\right)$
$= \left(- {x}^{2} - {e}^{x}\right) \left(- \sin x + 1\right) + \left(\cos x + x\right) \left(- 2 x - {e}^{x}\right)$
$= {x}^{2} \sin x - 3 {x}^{2} + {e}^{x} \sin x - {e}^{x} - 2 x \cos x - {e}^{x} \cos x - x {e}^{x}$

Which doesn't really clean up any more.