# How do you differentiate  f(x)=cos(e^((lnx-2)^2 )) using the chain rule.?

Feb 28, 2017

$- \frac{1}{x} \left(2 \ln x - 4\right) {e}^{{\left(\ln x - 2\right)}^{2}} \sin \left({e}^{{\left(\ln x - 2\right)}^{2}}\right)$

#### Explanation:

The chain rule says that

$\frac{d}{\mathrm{dx}} f \left(g \left(x\right)\right) = g ' \left(x\right) \cdot f ' \left(g \left(x\right)\right)$,

or that if you have one function inside another, the derivative of the whole thing will be the derivative of the inside multiplied by the derivative of the outside (with the inside left the same).

Therefore,

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

Here, I've used $| |$ notation to show that whatever is inside stays the same. In other words, only the $\cos$ is differentiated.

Based on the property that $\frac{d}{\mathrm{dx}} {e}^{a x + b} = a {e}^{a x + b}$, or the derivative of $e$ to some power is the derivative of the power multiplied by $e$ to the same power,

$\frac{d}{\mathrm{dx}} {e}^{{\left(\ln x - 2\right)}^{2}} = \frac{d}{\mathrm{dx}} {\left(\ln x - 2\right)}^{2} \cdot {e}^{{\left(\ln x - 2\right)}^{2}}$

Now, based on the chain rule again,

$\frac{d}{\mathrm{dx}} {\left(\ln x - 2\right)}^{2} = \frac{d}{\mathrm{dx}} \left(\ln x - 2\right) \cdot \frac{d}{\mathrm{dx}} | \left(\ln x - 2\right) {|}^{2}$

$= \frac{1}{x} \cdot 2 \left(\ln x - 2\right) = \frac{2 \ln x - 4}{x}$

Therefore,

$\frac{d}{\mathrm{dx}} {e}^{{\left(\ln x - 2\right)}^{2}} = \frac{2 \ln x - 4}{x} \cdot {e}^{{\left(\ln x - 2\right)}^{2}}$

Now we have the derivative of the inside of the original function. The derivative of the outside bit with the inside left the same is just

$\frac{d}{\mathrm{dx}} \cos = - \sin$, so

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

$\frac{2 \ln x - 4}{x} \cdot {e}^{{\left(\ln x - 2\right)}^{2}} \cdot - \sin \left({e}^{{\left(\ln x - 2\right)}^{2}}\right)$

$= - \frac{1}{x} \left(2 \ln x - 4\right) {e}^{{\left(\ln x - 2\right)}^{2}} \sin \left({e}^{{\left(\ln x - 2\right)}^{2}}\right)$