TITLE: Why does this differentation output correct result?
QUESTION [5 upvotes]: I noticed something funny. If you differentiate $x^x$ treating the exponent as a constant, you get $xx^{x-1}=x^x$. If you treat the base as a constant, you get $x^x
\ln{x}$. If you add these two bizzare and incorrect derivatives of $x^x$, you get $x^x(1+\ln{x})$, which is correct!
Is it merely a weird and funny coincidence or is it a part of a deeper result?
(I'm checking it for $(x^x)^x$, but it will take a while :) )

REPLY [6 votes]: This is a general phenomenon. In this case
$$x^x=f(x,x)$$
where
$$f(u,v)=u^v.$$
By the chain rule,
$$\frac{d}{dx}(x^x)=\frac d{dx}f(x,x)=f_1(x,x)+f_2(x,x)$$
where $f_1$ and $f_2$ are the partial derivatives of $f$.
In this case
$$f_1(u,v)=v u^{v-1}$$
(considering $v$ as constant) and
$$f_2(u,v)=(\ln u) u^v$$
(considering $u$ as constant). So $f_1(x,x)=x^x$ and $f_2(x,x)=(\ln x)x^x$.