Differentiate using the chain rule. Do not simplify. $$y = (\cos x)^{(\sin x)^x}$$
I'm not sure at all how to solve this problem. I know that the derivative of $a^x$ is $a^{x}ln(a)$. I know the derivative of $\cos(x)$ is $-\sin(x)$ and that the derivative of $\sin(x)$ is $\cos(x)$.
I assume that I start with $(\sin x)^x$. Will the derivative of that part be
$(\sin x)^{x}*\ln(\sin(x))*\cos(x)$
Does this rule work with the chain rule? Should I differentiate the $\ln(\sin(x))$ once more? I don't think so, but I'm quite confused, so a clarification would be nice.
This is the first problem which has so many "layers" and I'm not sure how to put the rest of the equation into the chain rule.
Thank you for the help.
 A: You need a combination of chain rule as well as logarithmic differentiation. Let the function be denoted by $y = f(x)$ so that $$y = (\cos x)^{(\sin x)^{x}}$$ and on taking logs we get $$\log y = (\sin x)^{x}\log\cos x$$ Further taking logs gives us $$\log\log y = x\log\sin x + \log\log\cos x$$ and then we differentiate using chain rule to get $$\frac{1}{\log y}\cdot\frac{1}{y}\cdot\frac{dy}{dx} = \log \sin x + x\cot x + \frac{1}{\log \cos x}\cdot\frac{-\sin x}{\cos x}$$ and finally we get
\begin{align}
\frac{dy}{dx} &= y\log y\left(\log\sin x + x\cot x - \frac{\tan x}{\log\cos x}\right)\notag\\
&= (\cos x)^{(\sin x)^{x}}(\sin x)^{x}\log \cos x\left(\log\sin x + x\cot x - \frac{\tan x}{\log\cos x}\right)\notag\\
\end{align}
Update: Note that the method of logarithmic differentiation is symbolic and does not take care of fine details. It does produce the correct answer, but there is a subtle mistake in above argument.
First of all note that the function $y = f(x) = (\cos x)^{(\sin x)^{x}}$ is defined only when both $\sin x$ and $\cos x$ are positive which means that $x$ lies in the first quadrant (excluding end points of the quadrant). Even if we assume that the value of $x$ is in first quadrant then $\log \cos x$ is defined but already negative and hence taking a second log is not justified so that we can't have an expression like $\log\log\cos x$. The way out is to differentiate $\log y = (\sin x)^{x}\log \cos x$ using product rule taking $$u = (\sin x)^{x}, v = \log\cos x, \log y = uv$$ In order to proceed further we need find $\dfrac{du}{dx}$ and for that we take logs to get $\log u = x\log \sin x$ and on differentiating we get $$\frac{1}{u}\cdot\frac{du}{dx} = x\cot x + \log \sin x$$ or $$u' = \frac{du}{dx} = (\sin x)^{x}(x\cot x + \log \sin x)$$ We then have $$\frac{1}{y}\cdot\frac{dy}{dx} = uv' + u'v = (\sin x)^{x}(-\tan x) + (\sin x)^{x}(x\cot x + \log \sin x)\log\cos x$$ or $$\frac{dy}{dx} = y(\sin x)^{x}\log\cos x\left(x\cot x + \log \sin x - \frac{\tan x}{\log\cos x}\right)$$ and putting value of $y$ we get the same answer as before.
A: I find it very easy to make mistakes when using the chain rule with exponent towers or just large functions in general. Instead, let's define the following functions and their derivatives:
$$f(x) = \ln(x) \Rightarrow f'(x) = \frac{1}{x}$$
$$g(x) = \cos(x)\Rightarrow g'(x) = -\sin(x)$$
$$h(x) = \sin(x)\Rightarrow h'(x) = \cos(x)$$
Then we know that
$$f(f(y)) = xf(h(x)) + f(f(g(x))$$
Apply the chain rule and product rule to differentiate both sides:
$$f'(f(y))f'(y)y' = [xf'(h(x))h'(x) + f(h(x))] + [f'(f(g(x))f'(g(x))g'(x)]$$
$$y' = \frac{xf'(h(x))h'(x) + f(h(x)) + f'(f(g(x))f'(g(x))g'(x)}{f'(f(y))f'(y)}$$
Replace with the functions
$$y' = \frac{x\frac{1}{\sin(x)}\cos(x) + \ln(\sin(x)) + \frac{1}{\ln(\cos(x))}\frac{1}{\cos(x)}(-\sin(x))}{\frac{1}{(\sin(x))^x\ln(\cos(x))}\frac{1}{(\cos(x))^{(\sin(x))^x}}}$$
This is equivalent to the accepted answer (change the divided trig functions to $\tan$ or $\cot$ and flip the bottom over).
I find this much easier because you compute $3$ simple derivatives, the natural logarithm, sine, and cosine. The only trick was using the logarithm to make it possible to express the function in simple form; but any time you have $(something)^x$, you should expect to do something equivalent to logarithmic differentiation.
After that, just apply the product rule and the chain rule to differentiate each side, and then divide by some terms from the LHS to isolate $y'$. For me at least, I'm much less likely to make arithmetic errors by pushing around letters than I am with actual values.
Then you can just replace each of the $f,g,h$ and $f',g',h'$ in the expression and simplify if necessary.
A: Generally you want to use exponentials and logs to unravel complicated powers.
$y = \cos(x)^{(\sin(x))^x} = e^{\ln\left(\cos(x)^{(\sin(x))^x}\right)}=e^{(\sin(x)^x\ln(\cos(x))} = e^{e^{\ln((\sin(x))^x)}\ln(\cos(x))} = e^{e^{x\ln(\sin(x))}\ln(\cos(x))}$
Now differentiating is a little more straight forward -- I guess...
$y' = e^{e^{x\ln(\sin(x))}\ln(\cos(x))} \cdot \dfrac{d}{dx}\left[e^{x\ln(\sin(x))}\ln(\cos(x))\right]$
$= e^{e^{x\ln(\sin(x))}\ln(\cos(x))} \cdot \left( \dfrac{d}{dx}\left[e^{x\ln(\sin(x))}\right]\ln(\cos(x))+e^{x\ln(\sin(x))}\dfrac{-\sin(x)}{\cos(x)}\right)$
$= e^{e^{x\ln(\sin(x))}\ln(\cos(x))} \cdot \left( e^{x\ln(\sin(x))}\left(\ln(\sin(x))+x\dfrac{\cos(x)}{\sin(x)}\right)\ln(\cos(x))+e^{x\ln(\sin(x))}\dfrac{-\sin(x)}{\cos(x)}\right)$
At this point, you could start collapsing exponentials and logs back down (if you needed to simplify).
