# How do you differentiate y=x^2sinx+xcosx?

Nov 10, 2016

$\frac{\mathrm{dy}}{\mathrm{dx}} = {x}^{2} \cos x + x \sin x + \cos x$

#### Explanation:

If you are studying maths, then you should learn the Product Rule for Differentiation, and practice how to use it:

$\frac{d}{\mathrm{dx}} \left(u v\right) = u \frac{\mathrm{dv}}{\mathrm{dx}} + \frac{\mathrm{du}}{\mathrm{dx}} v$, or, $\left(u v\right) ' = \left(\mathrm{du}\right) v + u \left(\mathrm{dv}\right)$

I was taught to remember the rule in words; "The first times the derivative of the second plus the derivative of the first times the second ".

This can be extended to three products:

$\frac{d}{\mathrm{dx}} \left(u v w\right) = u v \frac{\mathrm{dw}}{\mathrm{dx}} + u \frac{\mathrm{dv}}{\mathrm{dx}} w + \frac{\mathrm{du}}{\mathrm{dx}} v w$

So with $f \left(x\right) = {x}^{2} \sin x + x \cos x$ we will need to apply the product rule twice;

For the first component Let $y = {x}^{2} \sin x$
$\left\{\begin{matrix}\text{Let "u = x^2 & => & (du)/dx = 2x \\ "And } v = \sin x & \implies & \frac{\mathrm{dv}}{\mathrm{dx}} = \cos x\end{matrix}\right.$

$\frac{d}{\mathrm{dx}} \left(u v\right) = u \frac{\mathrm{dv}}{\mathrm{dx}} + \frac{\mathrm{du}}{\mathrm{dx}} v$
$\therefore \frac{d}{\mathrm{dx}} \left({x}^{2} \sin x\right) = \left({x}^{2}\right) \left(\cos x\right) + \left(2 x\right) \left(\sin x\right)$
$\therefore \frac{d}{\mathrm{dx}} \left({x}^{2} \sin x\right) = {x}^{2} \cos x + 2 x \sin x$ ..... [1]

For the second component Let $y = x \cos x$
$\left\{\begin{matrix}\text{Let "u = x & => & (du)/dx = 1 \\ "And } v = \cos x & \implies & \frac{\mathrm{dv}}{\mathrm{dx}} = - \sin x\end{matrix}\right.$

$\frac{d}{\mathrm{dx}} \left(u v\right) = u \frac{\mathrm{dv}}{\mathrm{dx}} + \frac{\mathrm{du}}{\mathrm{dx}} v$
$\therefore \frac{d}{\mathrm{dx}} \left(x \cos x\right) = \left(x\right) \left(- \sin x\right) + \left(1\right) \left(\cos x\right)$
$\therefore \frac{d}{\mathrm{dx}} \left(x \cos x\right) = \cos x - x \sin x$ ..... [2]

Combining the results [1] ad [2] we get;

$\frac{\mathrm{dy}}{\mathrm{dx}} = {x}^{2} \cos x + 2 x \sin x + \cos x - x \sin x$
$\therefore \frac{\mathrm{dy}}{\mathrm{dx}} = {x}^{2} \cos x + x \sin x + \cos x$