# How do you differentiate  g(x) = x^2-xsin3x ?

Dec 11, 2015

$2 x - \sin \left(3 x\right) - 3 x \cos \left(3 x\right)$

#### Explanation:

You must use three rules for differentiation:

1. The derivative of sum (or difference) of two or more functions is the sum (or difference) of each single derivative. So, in this case, we have
$\frac{d}{\mathrm{dx}} \left({x}^{2} - x \sin \left(3 x\right)\right) = \frac{d}{\mathrm{dx}} {x}^{2} - \frac{d}{\mathrm{dx}} x \sin \left(3 x\right)$
At this point, we can easily derive the first term, since the derivative of ${x}^{2}$ is $2 x$. Now let's work on the rest:

2. The derivative of a product $f \cdot g$ follows this rule:
$\frac{d}{\mathrm{dx}} \left(f \left(x\right) \cdot g \left(x\right)\right) = \left(\frac{d}{\mathrm{dx}} f \left(x\right)\right) \cdot g \left(x\right) + f \left(x\right) \cdot \left(\frac{d}{\mathrm{dx}} g \left(x\right)\right)$
$\left(\frac{d}{\mathrm{dx}} x\right) \cdot \sin \left(3 x\right) + x \cdot \left(\frac{d}{\mathrm{dx}} \sin \left(3 x\right)\right)$
Again, the derivative of $x$ is $1$, so the first term is simply $\sin \left(3 x\right)$ for the second term, we need the last rule:

3. The derivative of a composite function $f \left(g \left(x\right)\right)$ follows this rule:
$\frac{d}{\mathrm{dx}} f \left(g \left(x\right)\right) = \left(\frac{d}{\mathrm{dx}} f\right) \left(g \left(x\right)\right) \cdot \frac{d}{\mathrm{dx}} g \left(x\right)$
In your case, we have that
$\frac{d}{\mathrm{dx}} f = \frac{d}{\mathrm{dx}} \sin = \cos$, and so $\left(\frac{d}{\mathrm{dx}} f\right) \left(g \left(x\right)\right) = \cos \left(3 x\right)$
while $\frac{d}{\mathrm{dx}} g \left(x\right) = 3$

Put everything back together, and the result is

$2 x - \sin \left(3 x\right) - 3 x \cos \left(3 x\right)$