Derivatives

Derivative of x^x: Logarithmic Differentiation Explained

Derivative of x^x: Logarithmic Differentiation Explained — CalculusCalc cover image

Quick answer: for \( x > 0 \),

$$\frac{d}{dx}x^{x} = x^{x}\left(\ln x + 1\right)$$

Why neither basic rule works

  • The power rule needs a constant exponent: \( \frac{d}{dx}x^n = nx^{n-1} \).
  • The exponential rule needs a constant base: \( \frac{d}{dx}a^x = a^x\ln a \).

In \( x^x \) both the base and the exponent change, so we need a different tool: logarithmic differentiation.

Method 1: logarithmic differentiation

Let \( y = x^x \). Take the natural log of both sides and use \( \ln(a^b) = b\ln a \):

$$\ln y = x\ln x$$

Differentiate both sides. On the left use the chain rule; on the right the product rule:

$$\frac{1}{y}\frac{dy}{dx} = \ln x + x\cdot\frac1x = \ln x + 1$$

Multiply by \( y = x^x \):

$$\frac{dy}{dx} = x^x(\ln x + 1)$$

The left side is the step students most often skip. Because \( y \) is a function of \( x \), the derivative of \( \ln y \) is not \( \frac1y \) alone; the chain rule attaches a factor of \( \frac{dy}{dx} \). This is exactly the move used in implicit differentiation.

Method 2: rewrite with base e

Since \( x = e^{\ln x} \), we have \( x^x = e^{x\ln x} \). By the chain rule:

$$\frac{d}{dx}e^{x\ln x} = e^{x\ln x}\cdot(\ln x + 1) = x^x(\ln x + 1)$$

Both methods are really the same calculation. Method 1 hides the exponential; Method 2 shows it. Pick whichever you find easier to write cleanly under exam pressure.

Why the answer looks the way it does

Expand the answer and something neat appears:

$$x^x(\ln x + 1) = \underbrace{x\cdot x^{x-1}}_{\text{power rule}} + \underbrace{x^x\ln x}_{\text{exponential rule}}$$

The first term is what you get by freezing the exponent and using the power rule. The second is what you get by freezing the base and using the exponential rule. The true derivative is the sum of the two.

That is not a coincidence. When a quantity depends on \( x \) in two places, a small change in \( x \) nudges it through both routes at once, and for small changes the two effects add. So each “wrong” answer is really half of the right one. This is a useful memory aid, and it is the one-variable shadow of the multivariable chain rule you meet with partial derivatives.

Where is x^x smallest?

Set the derivative to zero. Since \( x^x > 0 \), we need \( \ln x + 1 = 0 \), so \( x = e^{-1} = \frac1e \approx 0.3679 \). The minimum value is

$$\left(\tfrac1e\right)^{1/e} = e^{-1/e} \approx 0.6922$$

This is a favorite exam question. You can confirm it with the critical points finder.

To prove it is a minimum rather than a maximum, differentiate once more. Using the product rule on \( x^x(\ln x + 1) \):

$$\frac{d^2}{dx^2}x^x = x^x(\ln x + 1)^2 + x^{x-1}$$

Both terms are positive for every \( x > 0 \), so the graph is concave up everywhere and the critical point must be a minimum. At \( x = \frac1e \) the first term vanishes and the second derivative equals \( e\cdot e^{-1/e} \approx 1.88 \).

Behavior near zero

The expression \( 0^0 \) is undefined, but the limit exists:

$$\lim_{x\to0^+}x^x = 1$$

Write \( x^x = e^{x\ln x} \). As \( x \to 0^+ \), the product \( x\ln x \to 0 \) (a standard L’Hôpital’s rule example), so \( x^x \to e^0 = 1 \). The slope, however, does not settle down: \( \ln x + 1 \to -\infty \) while \( x^x \to 1 \), so the derivative tends to \( -\infty \). The graph starts near height 1 with an almost vertical, downward tangent, dips to about 0.6922, and then climbs extremely fast.

Worked examples

1. Slope at x = 1. \( 1^1(\ln 1 + 1) = 1\cdot 1 = 1 \). The point is \( (1, 1) \), so the tangent line there is simply \( y = x \).

2. Slope at x = 2. The derivative is \( 4(\ln 2 + 1) \approx 6.77 \). The tangent line is

$$y - 4 = 4(\ln 2 + 1)(x - 2)$$

3. \( x^{\sin x} \): \( \ln y = \sin x\ln x \), so

$$\frac{dy}{dx} = x^{\sin x}\left(\cos x\ln x + \frac{\sin x}{x}\right)$$

4. \( x^{1/x} \): \( \ln y = \frac{\ln x}{x} \), so

$$\frac{dy}{dx} = x^{1/x}\cdot\frac{1 - \ln x}{x^2}$$

It peaks at \( x = e \), which proves \( e^{1/e} \) is the largest value of \( x^{1/x} \).

5. \( x^{x^2} \): \( \ln y = x^2\ln x \), so \( y' = x^{x^2}(2x\ln x + x) \).

6. \( (\ln x)^x \) for \( x > 1 \). Now the base is itself a function. Take logs: \( \ln y = x\ln(\ln x) \). The product rule, with the chain rule on the second factor, gives

$$\frac{y'}{y} = \ln(\ln x) + x\cdot\frac{1}{\ln x}\cdot\frac1x$$

so \( y' = (\ln x)^x\left(\ln(\ln x) + \frac{1}{\ln x}\right) \). The restriction \( x > 1 \) keeps the base positive.

General formula

For \( y = f(x)^{g(x)} \) with \( f(x) > 0 \):

$$\frac{dy}{dx} = f^{g}\left(g'\ln f + \frac{g\,f'}{f}\right)$$

Read it the same way as before: the \( g'\ln f \) part is the exponential-rule piece and the \( \frac{g f'}{f} \) part is the power-rule piece.

Where it’s used

Functions with a variable exponent show up more often than you might expect. The expression \( \left(1 + \frac1x\right)^x \), whose limit defines \( e \), is one: logarithmic differentiation is how you show it increases steadily toward \( e \). Growth comparisons are another, since writing a function as \( e^{g(x)} \) lets you compare exponents instead of towers of powers. And in probability and statistics, likelihood functions are products of many factors, which are routinely handled by taking logs first for exactly the reasons shown below.

Comparing x², 2^x and x^x

It helps to line up the three look-alike functions and the rule each one needs:

Function What varies Rule Derivative
\( x^2 \) base only power rule \( 2x \)
\( 2^x \) exponent only exponential rule \( 2^x\ln 2 \)
\( x^x \) both logarithmic differentiation \( x^x(\ln x + 1) \)

Before you differentiate, ask one question: does \( x \) appear in the base, the exponent, or both? That single check tells you which row you are in and prevents the most common error on this topic.

For large \( x \), \( x^x \) grows much faster than \( 2^x \), because its base keeps increasing too. The derivative reflects this: the factor \( \ln x + 1 \) itself grows without bound, so the slope outruns the function value by a larger and larger factor.

Bonus: the same trick for messy products

Logarithmic differentiation is not only for variable exponents. It also turns long products and quotients into sums, which are much easier to differentiate. Take

$$y = \frac{x^3(x+1)^4}{x^2+1}$$

Logs split the product apart:

$$\ln y = 3\ln x + 4\ln(x+1) - \ln(x^2+1)$$

Each term now needs only a one-step chain rule:

$$\frac{y'}{y} = \frac{3}{x} + \frac{4}{x+1} - \frac{2x}{x^2+1}$$

Multiply by \( y \) to finish. Compare this with applying the product rule and the quotient rule together: the log route has far fewer places to drop a term.

Common mistakes

  • Using only the power rule. Writing \( x\cdot x^{x-1} = x^x \) misses the \( x^x\ln x \) term.
  • Using only the exponential rule. Writing \( x^x\ln x \) misses the other half. The correct answer is the sum of both.
  • Forgetting to multiply back by y. After differentiating \( \ln y \) you have \( \frac{y'}{y} \). The final step is always \( y' = y\cdot(\dots) \), with \( y \) replaced by the original function.
  • Skipping the product rule. The right side \( x\ln x \) is a product, so its derivative is \( \ln x + 1 \), not \( \frac1x \).
  • Ignoring the domain. Logarithmic differentiation needs a positive base, so state \( x > 0 \) (or whatever keeps the base positive).

Try it yourself

Step-by-step solverExact symbolic engine

Interactive Calculus Problem Solver

Derivatives, antiderivatives, definite and improper integrals, and limits. Every answer comes with the rules used, and antiderivatives are verified by differentiating them back.

Try:
Input syntax
  • Powers x^2, roots sqrt(x), cbrt(x), absolute value |x|
  • Implicit multiplication works: 3x sin(2x)
  • sin cos tan sec csc cot, asin acos atan, sinh cosh tanh
  • e^x or exp(x); ln(x) and log(x) are both the natural log
  • Constants pi and e; bounds accept inf and -inf
Enter a function and press Solve to see a full worked solution.

For other variable-exponent functions, type them into the derivative calculator and compare its answer with your logarithmic differentiation.

Practice problems

Try these before checking the answers.

  1. \( \frac{d}{dx}x^{2x} \)
  2. \( \frac{d}{dx}x^{\ln x} \)
  3. \( \frac{d}{dx}(\sin x)^{x}\ \text{on } (0,\pi) \)
  4. \( \frac{d}{dx}x^{\sqrt x} \)
  5. \( \frac{d}{dx}(x^2 + 1)^{x} \)
  6. The slope of \( y = x^x \) at \( x = 2 \), exactly.

Answers: (1) \( x^{2x}(2\ln x + 2) \); (2) \( x^{\ln x}\cdot\frac{2\ln x}{x} \); (3) \( (\sin x)^x\left(\ln\sin x + x\cot x\right) \); (4) \( x^{\sqrt x}\left(\frac{\ln x}{2\sqrt x} + \frac{1}{\sqrt x}\right) \); (5) \( (x^2+1)^x\left(\ln(x^2+1) + \frac{2x^2}{x^2+1}\right) \); (6) \( 4 + 4\ln 2 \).

FAQ

Is the derivative of x^x equal to x·x^(x−1)?

No. That treats the exponent as a constant and gives \( x^x \), which misses the \( x^x\ln x \) term.

What about x^x for negative x?

\( x^x \) is not defined for most negative real numbers, so the derivative is only discussed for \( x > 0 \).

What is the second derivative of x^x?

It is \( x^x(\ln x + 1)^2 + x^{x-1} \). You get it by applying the product rule to the first derivative, using the fact that the derivative of \( x^x \) is \( x^x(\ln x + 1) \) again inside the calculation.

What is the integral of x^x?

There is no antiderivative in terms of elementary functions. Definite integrals can still be computed numerically; for example, the area under \( x^x \) from 0 to 1 is about 0.7834.

Why do we take the natural log and not log base 10?

Any base would work, but the derivative of \( \ln y \) is the cleanest: \( \frac{y'}{y} \), with no extra constant. See derivative of ln x for why.

Further reading

Calculators for this topic

Leave a comment

Your email address will not be published. Required fields are marked *