I am asked to find the derivative of
$$ f: (0, \infty) \to \mathbb{R},~x \mapsto x^{\ln(x)} $$
I am aware that I can rewrite it as $f(x) = e^{\ln^2(x)}$, and easily differentiate but I wanted to use the chain rule on the original function. Here's my work:
The chain rule states $$ \frac{d}{dx}~g(h(x)) = g'(h(x))\cdot h'(x) $$ In this example, the 'outer' function is $g(x) := x^x$ with $g'(x) = x^x (\log(x) + 1)$ and the 'inner' function is $h(x) := \ln(x)$ with $h'(x) = x^{-1}$.
Appling the chain rule from above, I obtain
$$ f'(x) = \ln(x) ^{\ln(x)}~(\ln(\ln(x) + 1 )~\frac{1}{x} $$
When I let WolframAlpha plot this, I recognised my solution to be vastly different from the proposed solution $$ f'(x) = \frac{2}{x}~\ln(x)~x^{\ln(x)} $$ Where have I gone wrong?
I assume you already saw your mistake as pointed in the comments and in @gimusi's answer. A different approach (and one I find useful) is to take take $\log$ of your exponential function:
Let $y=\log(x^{\log(x)})=\log^2(x)$ and note that $e^y=x^{\log(x)}$. Then you have that
$$\frac{dy}{dx}=\frac{2\log(x)}{x}$$
Hence you have that $$\frac{d(x^{\log(x)})}{dx}=\frac{d(e^y)}{dx}=e^y\frac{dy}{dx}=x^{\log(x)}\frac{2\log(x)}{x}$$
which is the answer you want