Derivative of $x^x$ and the chain rule

Rewriting $x^x$ as $e^{x\ln{x}}$ we can then easily calculte the ${\frac{x}{dx}}$ derivative as ${x^x}(1 + \ln{x})$. We need to use chain rule in form $\frac{de^u}{du}\frac{du}{dx}$. The question is why cannot we use the chain rule skipping the 1st step of rewriting $x^x$ as $e^{xlnx}$? The idea would be to write $\frac{u^x}{du}\frac{du}{dx}$ which simply would be $x^x\ln{x} \cdot 1$? The answer is incorrect, here we are missing the $+x^x$ term.


$$\frac{d(a^x)}{dx}=a^x\ln a$$ is true only for constant $a\gt0$.


Note that in getting the above result, the steps followed are similar to the steps for getting the derivative of $x^x$.

Let $f(x)=a^x$, $a\gt0$. Then, $$f(x)=e^{x\ln a}$$ $$f'(x)=\frac{d(e^{x\ln a})}{d(x\ln a)}\cdot\frac{d(x\ln a)}{dx}=e^{x\ln a}\cdot\ln a=a^x\ln a$$

whereas, for $f(x)=x^x$, $x\gt0$, $$f(x)=e^{x\ln x}$$ $$f'(x)=\frac{d(e^{x\ln x})}{d(x\ln x)}\cdot\frac{d(x\ln x)}{dx}=e^{x\ln x}\cdot(\ln x+1)=x^x(\ln x+1)$$


There is a "generalized" power rule I always taught. You can memorize it or not, but it is easy to derive if needed. If $f$ and $g$ are functions of $x$, then

$$\left(f^g\right)' = gf^{g-1}\cdot f' + f^g\log f\cdot g'$$

(To help remember this, notice that the first term is like the power rule with constant exponent, and the second term is like the power rule with constant base.)

Note that if $g$ is constant, then $g'\equiv 0$ and this reduces to the familiar rule $$\left(u^n\right)'=nu^{n-1}\cdot u'$$ and if $f$ is constant then this reduces to the familiar rule $$\left(a^u\right)'=a^u\log a\cdot u'$$

In your case, $f(x)=g(x)=x$ and we have $$\left(x^x\right)'=xx^{x-1}\cdot 1 + x^x\log x\cdot 1 = x^x(1+\log x)$$