What is the derivative of $x^x$? The variable is in the base and the exponent, so neither the power rule nor the exponential rule applies. Logarithms bring the exponent down, and Implicit Differentiation finishes the job.
Key idea
Logarithmic differentiation: when $y$ is a messy product, quotient or power, take $\ln$ of both sides, expand with log rules, differentiate implicitly ($\frac{d}{dx}\ln y = \frac{y'}{y}$), then multiply by $y$. For $y = x^x$ this gives $$y' = x^x(\ln x + 1).$$
Why it works
Logarithms turn hard operations into easy ones: products into sums, quotients into differences, and powers into multiples ($\ln a^b = b\ln a$). Sums and multiples are easy to differentiate. The price is a factor of $\frac{1}{y}$ on the left, which we clear at the end by multiplying by $y$. This also proves the power rule for every real $n$: if $y = x^n$, then $\ln y = n\ln x$, so $\frac{y'}{y} = \frac{n}{x}$ and $y' = \frac{n}{x}x^n = nx^{n-1}$.
Worked example: The classic
Differentiate $y = x^x$ ($x > 0$).
- $\ln y = x\ln x$.
- Differentiate: $\frac{y'}{y} = \ln x + x\cdot\frac{1}{x} = \ln x + 1$.
- Multiply by $y$: $y' = x^x(\ln x + 1)$.
Answer: $y' = x^x(\ln x + 1)$
Worked example: A function as the exponent
Differentiate $y = x^{\sin x}$ ($x > 0$).
- $\ln y = \sin x\,\ln x$.
- Product rule: $\frac{y'}{y} = \cos x\ln x + \frac{\sin x}{x}$.
- $y' = x^{\sin x}\left(\cos x\ln x + \frac{\sin x}{x}\right)$.
Answer: $x^{\sin x}\left(\cos x\ln x + \frac{\sin x}{x}\right)$
Worked example: A messy quotient
For $y = \dfrac{x^2(x + 1)^3}{(x + 2)^4}$, find $y'(1)$.
- $\ln y = 2\ln x + 3\ln(x + 1) - 4\ln(x + 2)$.
- $\frac{y'}{y} = \frac{2}{x} + \frac{3}{x + 1} - \frac{4}{x + 2}$.
- At $x = 1$: $y(1) = \frac{1\cdot 8}{81} = \frac{8}{81}$ and $\frac{y'}{y} = 2 + \frac{3}{2} - \frac{4}{3} = \frac{13}{6}$.
- $y'(1) = \frac{8}{81}\cdot\frac{13}{6} = \frac{52}{243}$.
Answer: $\frac{52}{243}$
When to use it
- A variable in both the base and the exponent: $x^x$, $x^{\sin x}$, $(x^2 + 1)^x$. Here it is the only practical route.
- A long product or quotient of powers, where the product and quotient rules would be messy.
- Remember the domain: $\ln y$ needs $y > 0$. For functions that can be negative, use $\ln\lvert y \rvert$; the result is the same.
Common mistake
Treating $x^x$ with one rule alone: the power rule gives $x\cdot x^{x-1} = x^x$, and the exponential rule gives $x^x\ln x$. Each misses half the story. The correct derivative, $x^x(\ln x + 1)$, is in fact their sum. Check at $x = 2$: the true slope is $4(\ln 2 + 1) \approx 6.77$, while the two partial answers give $4$ and $4\ln 2 \approx 2.77$.