TITLE: Derivative of $x^{x^x}$
QUESTION [19 upvotes]: I need to compute the derivative of $$z=x^{x^x}$$
I made it like this:
$$y=x^x$$ so $$z=y^x$$
then $$\ln(z)=x\ln(y)$$ 
taking derivative from both sides:
$$\frac{z'}{z}=\ln(y)+x\left(\frac{1}{y}\right)y'$$
I know that $$(x^x)'=x^x(1+\ln(x))$$
So : $$z'=z*(\ln(x^x)+x*\left(\frac{1}{x^x}\right)*(x^x)'))=x^{x^x}(x\ln(x)+x\ln(x)+x)=x^{x^x}\left(2x\ln(x)+x\right)$$ I know I did something wrong. Where is my Mistake??
Thanks alot!

REPLY [2 votes]: Let us first establish the derivative of $x^{f(x)}$ in general.
$$\left(x^{f(x)}\right)'=\left(e^{\ln x f(x)}\right)'=\left(\frac{f(x)}x+\ln x f'(x)\right)x^{f(x)}.$$
Then
$$(x^x)'=\color{blue}{\left(1+\ln x\right)x^{x}}$$
and
$$\left(x^{x^x}\right)'=\left(\frac{x^x}x+\ln x \color{blue}{\left(1+\ln x\right)x^{x}}\right)x^{{x^x}}=\color{green}{\left(\frac1x+\ln x+\ln^2x\right)x^xx^{x^x}}.$$

While we are at it:
$$\left(x^{x^{x^x}}\right)'=\left(\frac{x^{x^x}}x+\ln x \color{green}{\left(\frac1x+\ln x+\ln^2x\right)x^xx^{x^x}}\right)x^{x^{x^x}}.$$