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

May 29, 2016

First you use production rule to get

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

Then use the linearity of the derivative and function derivative definitions to get

$\frac{d}{\mathrm{dx}} f \left(x\right) = \cos x + 2 \sin x - 3 {e}^{x} \cos x - {e}^{x} \sin x - x \sin x + 2 x \cos x$

#### Explanation:

Product rule involves taking the derivative of function which are multiples of two (or more) functions, in the form $f \left(x\right) = g \left(x\right) \cdot h \left(x\right)$. The product rule is

$\frac{d}{\mathrm{dx}} f \left(x\right) = \left(\frac{d}{\mathrm{dx}} g \left(x\right)\right) \cdot h \left(x\right) + g \left(x\right) \cdot \left(\frac{d}{\mathrm{dx}} h \left(x\right)\right)$ .

Applying it to our function,
$f \left(x\right) = \left(x - {e}^{x}\right) \left(\cos x + 2 \sin x\right)$

We have

$\frac{d}{\mathrm{dx}} f \left(x\right) = \left(\frac{d}{\mathrm{dx}} \left(x - {e}^{x}\right)\right) \left(\cos x + 2 \sin x\right) + \left(x - {e}^{x}\right) \left(\frac{d}{\mathrm{dx}} \left(\cos x + 2 \sin x\right)\right)$ .

Additionally we need to use the linearity of the derivation, that

$\frac{d}{\mathrm{dx}} \left(a \cdot f \left(x\right) + b \cdot g \left(x\right)\right) = a \cdot \left(\frac{d}{\mathrm{dx}} f \left(x\right)\right) + b \cdot \left(\frac{d}{\mathrm{dx}} g \left(x\right)\right)$ .

Applying this we have

$\frac{d}{\mathrm{dx}} f \left(x\right) = \left(\frac{d}{\mathrm{dx}} \left(x\right) - \frac{d}{\mathrm{dx}} \left({e}^{x}\right)\right) \left(\cos x + 2 \sin x\right) + \left(x - {e}^{x}\right) \left(\frac{d}{\mathrm{dx}} \left(\cos x\right) + 2 \cdot \frac{d}{\mathrm{dx}} \left(\sin x\right)\right)$ .

We need to do the individual derivatives of these functions, we use

$\frac{d}{\mathrm{dx}} {x}^{n} = n \cdot {x}^{n - 1}$       $\frac{d}{\mathrm{dx}} {e}^{x} = {e}^{x}$

$\frac{d}{\mathrm{dx}} \sin x = \cos x$       $\frac{d}{\mathrm{dx}} \cos x = - \sin x$ .

Now we have

$\frac{d}{\mathrm{dx}} f \left(x\right) = \left(1 \cdot {x}^{0} - {e}^{x}\right) \left(\cos x + 2 \sin x\right) + \left(x - {e}^{x}\right) \left(- \sin x + 2 \cos x\right)$ .

$\frac{d}{\mathrm{dx}} f \left(x\right) = \left(1 - {e}^{x}\right) \left(\cos x + 2 \sin x\right) + \left(x - {e}^{x}\right) \left(- \sin x + 2 \cos x\right)$

At this point we just neaten a bit

$\frac{d}{\mathrm{dx}} f \left(x\right) = \left(\cos x + 2 \sin x\right) - {e}^{x} \left(\cos x + 2 \sin x\right) + x \left(- \sin x + 2 \cdot \cos x\right) + {e}^{x} \left(\sin x - 2 \cos x\right)$

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

$\frac{d}{\mathrm{dx}} f \left(x\right) = \cos x + 2 \sin x - 3 {e}^{x} \cos x - {e}^{x} \sin x - x \sin x + 2 x \cos x$