# How do you differentiate f(x)=(ln(sinx)^2-3xln(sinx)+x^2ln(cos^2x^2) using the chain rule?

##### 1 Answer
Dec 17, 2017

Take the derivative of each term, using the product rule and chain rule, to get

$\frac{\mathrm{df}}{\mathrm{dx}} = 2 \ln \left(\sin \left(x\right)\right) \csc \left(x\right) \cos \left(x\right) - 3 x \csc \left(x\right) \cos \left(x\right) - 3 \ln \left(\sin \left(x\right)\right) - 4 {x}^{3} \sin \left({x}^{2}\right) \sec \left({x}^{2}\right) + 2 x \ln \left({\left(\cos \left({x}^{2}\right)\right)}^{2}\right)$

which may be factored as needed.

#### Explanation:

Here is our function:

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

Taking the derivative, we should have three smaller parts:

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

Let's label them:

$g \left(x\right) = \ln {\left(\sin x\right)}^{2}$

$h \left(x\right) = 3 x \ln \left(\sin x\right)$

$p \left(x\right) = {x}^{2} \ln \left({\cos}^{2} {x}^{2}\right)$

So it becomes:

$\frac{\mathrm{df}}{\mathrm{dx}} = \frac{\mathrm{dg}}{\mathrm{dx}} - \frac{\mathrm{dh}}{\mathrm{dx}} + \frac{\mathrm{dp}}{\mathrm{dx}}$

Let's find the derivatives one-by-one, starting from $g \left(x\right)$. Let's... break this function composition down.

${g}_{1} \left(x\right) = \sin \left(x\right)$

${g}_{2} \left(x\right) = \ln \left(x\right)$

${g}_{3} \left(x\right) = {x}^{2}$

So $g \left(x\right) = {g}_{3} \left({g}_{2} \left({g}_{1} \left(x\right)\right)\right)$. Let's take the derivative, one by one, using the chain rule:

${\mathrm{dg}}_{1} = d \left(\sin \left(x\right)\right) = \cos \left(x\right) \mathrm{dx}$

$\frac{{\mathrm{dg}}_{1}}{\mathrm{dx}} = \cos \left(x\right)$

${\mathrm{dg}}_{2} = d \left(\ln \left({g}_{1}\right)\right) = {\left({g}_{1}\right)}^{-} 1 {\mathrm{dg}}_{1} = {\left(\sin \left(x\right)\right)}^{-} 1 \cos \left(x\right) \mathrm{dx}$

$\frac{{\mathrm{dg}}_{2}}{\mathrm{dx}} = \csc \left(x\right) \cos \left(x\right)$

${\mathrm{dg}}_{3} = d \left({\left({g}_{2}\right)}^{2}\right) = 2 {g}_{2} {\mathrm{dg}}_{2} = 2 \ln \left({g}_{1}\right) \csc \left(x\right) \cos \left(x\right) \mathrm{dx}$
$= 2 \ln \left(\sin \left(x\right)\right) \csc \left(x\right) \cos \left(x\right) \mathrm{dx}$

$\frac{{\mathrm{dg}}_{3}}{\mathrm{dx}} = 2 \ln \left(\sin \left(x\right)\right) \csc \left(x\right) \cos \left(x\right)$

Therefore $\frac{\mathrm{dg}}{\mathrm{dx}} = 2 \ln \left(\sin \left(x\right)\right) \csc \left(x\right) \cos \left(x\right)$. Substitute that back:

$\frac{\mathrm{df}}{\mathrm{dx}} = 2 \ln \left(\sin \left(x\right)\right) \csc \left(x\right) \cos \left(x\right) - \frac{\mathrm{dh}}{\mathrm{dx}} + \frac{\mathrm{dp}}{\mathrm{dx}}$

Now, on to $\frac{\mathrm{dh}}{\mathrm{dx}}$.

First using the product rule, we have that

$\mathrm{dh} = d \left(3 x \ln \left(\sin x\right)\right) = 3 x \cdot d \left(\ln \left(s i x \left(x\right)\right)\right) + \ln \left(\sin \left(x\right)\right) \cdot d \left(3 x\right)$

Then we need to find $d \left(3 x\right)$ and $d \left(\ln \left(\sin \left(x\right)\right)\right)$. The first one is easy:

$\frac{d \left(3 x\right)}{\mathrm{dx}} = 3 \rightarrow d \left(3 x\right) = 3 \mathrm{dx}$

Putting that back:

$\left(\mathrm{dh}\right) = 3 x \cdot d \left(\ln \left(\sin \left(x\right)\right)\right) + 3 \ln \left(\sin \left(x\right)\right) \mathrm{dx}$

As for $d \left(\ln \left(\sin \left(x\right)\right)\right)$... well, this happens to be the same as the ${\mathrm{dg}}_{2}$ we calculated earlier, so:

$\left(\mathrm{dh}\right) = 3 x \csc \left(x\right) \cos \left(x\right) \mathrm{dx} + 3 \ln \left(\sin \left(x\right)\right) \mathrm{dx}$

$\frac{\mathrm{dh}}{\mathrm{dx}} = 3 x \csc \left(x\right) \cos \left(x\right) + 3 \ln \left(\sin \left(x\right)\right)$

Substituting this back:

$\frac{\mathrm{df}}{\mathrm{dx}} = 2 \ln \left(\sin \left(x\right)\right) \csc \left(x\right) \cos \left(x\right) - 3 x \csc \left(x\right) \cos \left(x\right) - 3 \ln \left(\sin \left(x\right)\right) + \frac{\mathrm{dp}}{\mathrm{dx}}$

For $\frac{\mathrm{dp}}{\mathrm{dx}}$, we'll use the product rule again:

$\mathrm{dp} = {x}^{2} d \left(\ln \left({\cos}^{2} {x}^{2}\right)\right) + \ln \left({\cos}^{2} {x}^{2}\right) d \left({x}^{2}\right)$

Let's do $d \left({x}^{2}\right)$:

$\frac{d \left({x}^{2}\right)}{\mathrm{dx}} = 2 x \rightarrow d \left({x}^{2}\right) = 2 x \mathrm{dx}$

Put it back:

$\mathrm{dp} = {x}^{2} d \left(\ln \left({\cos}^{2} {x}^{2}\right)\right) + 2 x \ln \left({\cos}^{2} {x}^{2}\right) \mathrm{dx}$

Now we just need $d \left(\ln \left({\cos}^{2} {x}^{2}\right)\right)$, which is more like $d \left(\ln \left({\left(\cos \left({x}^{2}\right)\right)}^{2}\right)\right)$, and we'll label $\mathrm{dq}$:

$\mathrm{dp} = {x}^{2} \mathrm{dq} + 2 x \ln \left({\left(\cos \left({x}^{2}\right)\right)}^{2}\right) \mathrm{dx}$

Let's break down the composition of $\mathrm{dq}$:

${q}_{1} \left(x\right) = {x}^{2}$

${q}_{2} \left(x\right) = \cos \left(x\right)$

${q}_{3} \left(x\right) = {x}^{2}$

${q}_{4} \left(x\right) = \ln \left(x\right)$

So $q \left(x\right) = {q}_{4} \left({q}_{3} \left({q}_{2} \left({q}_{1} \left(x\right)\right)\right)\right)$. Yes, ${q}_{1}$ and ${q}_{3}$ are the same, but when peeling off the onion, we need different layers to be labeled differently.

$\frac{{\mathrm{dq}}_{1}}{\mathrm{dx}} = 2 x \rightarrow {\mathrm{dq}}_{1} = 2 x \mathrm{dx}$

${\mathrm{dq}}_{2} = d \left(\cos \left({q}_{1}\right)\right) = - \sin \left({q}_{1}\right) {\mathrm{dq}}_{1} = - \sin \left({x}^{2}\right) 2 x \mathrm{dx}$

$\frac{{\mathrm{dq}}_{2}}{\mathrm{dx}} = - \sin \left({x}^{2}\right) 2 x$

${\mathrm{dq}}_{3} = d \left({\left({q}_{2}\right)}^{2}\right) = 2 {q}_{2} {\mathrm{dq}}_{2} = 2 \cos \left({q}_{1}\right) \cdot - \sin \left({x}^{2}\right) 2 x \mathrm{dx}$
$= - 4 x \sin \left({x}^{2}\right) \cos \left({x}^{2}\right) \mathrm{dx}$

$\frac{{\mathrm{dq}}_{3}}{\mathrm{dx}} = - 4 x \sin \left({x}^{2}\right) \cos \left({x}^{2}\right)$

${\mathrm{dq}}_{4} = d \left(\ln \left({q}_{3}\right)\right) = {\left({q}_{3}\right)}^{-} 1 {\mathrm{dq}}_{3}$
$= {\left({q}_{2}\right)}^{-} 2 \cdot - 4 x \sin \left({x}^{2}\right) \cos \left({x}^{2}\right) \mathrm{dx}$
$= {\left(\cos \left({q}_{1}\right)\right)}^{-} 2 \cdot - 4 x \sin \left({x}^{2}\right) \cos \left({x}^{2}\right) \mathrm{dx}$
$= {\left(\cos \left({x}^{2}\right)\right)}^{-} 2 \cdot - 4 x \sin \left({x}^{2}\right) \cos \left({x}^{2}\right) \mathrm{dx}$
$= - 4 x \sin \left({x}^{2}\right) \cos \left({x}^{2}\right) {\left(\cos \left({x}^{2}\right)\right)}^{-} 2 \mathrm{dx}$
$= - 4 x \sin \left({x}^{2}\right) {\left(\cos \left({x}^{2}\right)\right)}^{-} 1 \mathrm{dx}$
$= - 4 x \sin \left({x}^{2}\right) \sec \left({x}^{2}\right) \mathrm{dx}$

$\frac{{\mathrm{dq}}_{4}}{\mathrm{dx}} = - 4 x \sin \left({x}^{2}\right) \sec \left({x}^{2}\right)$

So,

$\frac{\mathrm{dq}}{\mathrm{dx}} = - 4 x \sin \left({x}^{2}\right) \sec \left({x}^{2}\right) \rightarrow \mathrm{dq} = - 4 x \sin \left({x}^{2}\right) \sec \left({x}^{2}\right) \mathrm{dx}$

Let's substitute this back into $\frac{\mathrm{dp}}{\mathrm{dx}}$:

$\mathrm{dp} = {x}^{2} \cdot - 4 x \sin \left({x}^{2}\right) \sec \left({x}^{2}\right) \mathrm{dx} + 2 x \ln \left({\left(\cos \left({x}^{2}\right)\right)}^{2}\right) \mathrm{dx}$

$\mathrm{dp} = - 4 {x}^{3} \sin \left({x}^{2}\right) \sec \left({x}^{2}\right) \mathrm{dx} + 2 x \ln \left({\left(\cos \left({x}^{2}\right)\right)}^{2}\right) \mathrm{dx}$

$\frac{\mathrm{dp}}{\mathrm{dx}} = - 4 {x}^{3} \sin \left({x}^{2}\right) \sec \left({x}^{2}\right) + 2 x \ln \left({\left(\cos \left({x}^{2}\right)\right)}^{2}\right)$

And finally this into $\frac{\mathrm{df}}{\mathrm{dx}}$:

$\frac{\mathrm{df}}{\mathrm{dx}} = 2 \ln \left(\sin \left(x\right)\right) \csc \left(x\right) \cos \left(x\right) - 3 x \csc \left(x\right) \cos \left(x\right) - 3 \ln \left(\sin \left(x\right)\right) - 4 {x}^{3} \sin \left({x}^{2}\right) \sec \left({x}^{2}\right) + 2 x \ln \left({\left(\cos \left({x}^{2}\right)\right)}^{2}\right)$