Logarithmic differentiation

When the variable is in the base and the exponent at once, take logarithms first.

\[\frac{d}{dx}f^{g} = f^{g}\left(g'\ln f + \frac{gf'}{f}\right)\]

What it says

For \(x^{x}\) neither standard rule fits: the power rule needs a constant exponent, the exponential rule a constant base. Taking logarithms fixes it, because \(\ln\) turns an exponent into an ordinary factor.

Write \(y = f^{g}\). Then \(\ln y = g\ln f\); differentiating both sides gives \(\frac{y'}{y} = g'\ln f + \frac{gf'}{f}\), and multiplying by \(y = f^{g}\) gives the formula above. The two terms have a clear reading: the first is the change coming from the exponent, the second from the base.

The same trick is useful even when it is not required. A long product or quotient can be turned into a sum of logarithms, differentiated term by term, then multiplied back — often much less work than nested product rules.

When it applies

  • The variable appears in both the base and the exponent.
  • Towers such as \(x^{x}\), \(x^{\sin x}\) or \((\sin x)^{\cos x}\).
  • Optionally, to tame a product or quotient with many factors.

Five worked examples

Every line is the step the calculator would show, in the order it applies them. Each graph is live: hover it to read both curves and see the tangent whose slope is the derivative, drag to pan, scroll to zoom.

Example 1
\[\frac{d}{dx}\left[x^{x}\right]\]
  1. Take logs: \(\ln y = x\ln x\).

    \[\frac{y'}{y} = \frac{d}{dx}\left[x\ln x\right] = \ln x + 1\]
  2. Multiply back by \(y = x^{x}\).

    \[= x^{x}\left(\ln x + 1\right)\]
Answer
\[x^{x} \left(\ln\left(x\right) + 1\right)\]

Only for \(x > 0\). The curve dips into a shallow trough near the left edge, then rises so fast that the framing pulls in to keep it on screen. f′ climbs from below the axis, through zero at the trough, and away.

Zero at \(x = \frac{1}{e}\), which is where \(x^{x}\) reaches its minimum of about \(0.6922\).

Open x^x in the calculator
Example 2
\[\frac{d}{dx}\left[x^{\sin\left(x\right)}\right]\]
  1. With \(f = x\) and \(g = \sin x\), so \(f' = 1\) and \(g' = \cos x\).

    \[= x^{\sin x}\left(\cos x\,\ln x + \frac{\sin x}{x}\right)\]
Answer
\[x^{\sin\left(x\right)} \left(\cos\left(x\right) \ln\left(x\right) + \frac{\sin\left(x\right)}{x}\right)\]

An unruly curve — the base grows while the exponent oscillates — but f′ is still zero at each turning point of f.

The first term is the exponent changing, the second the base changing.

Open x^sin(x) in the calculator
Example 3
\[\frac{d}{dx}\left[\sin\left(x\right)^{\cos\left(x\right)}\right]\]
  1. Now \(f = \sin x\), \(g = \cos x\), \(f' = \cos x\), \(g' = -\sin x\).

    \[= \left(\sin x\right)^{\cos x}\left(-\sin x\,\ln \sin x + \frac{\cos^{2}x}{\sin x}\right)\]
Answer
\[\sin\left(x\right)^{\cos\left(x\right)} \left(\left(-\sin\left(x\right)\right) \ln\left(\sin\left(x\right)\right) + \frac{\cos^{2}\left(x\right)}{\sin\left(x\right)}\right)\]

Defined only where \(\sin x > 0\), so the curve appears in arches, with f′ steep at both edges of each one.

Only valid where \(\sin x > 0\), since the logarithm of the base has to exist.

Open sin(x)^cos(x) in the calculator
Example 4
\[\frac{d}{dx}\left[x^{\frac{1}{x}}\right]\]
  1. \(f = x\), \(g = \frac{1}{x}\), so \(g' = -\frac{1}{x^{2}}\).

    \[= x^{1/x}\left(-\frac{\ln x}{x^{2}} + \frac{1}{x}\cdot\frac{1}{x}\right)\]
  2. Collect over \(x^{2}\).

    \[= x^{1/x}\,\frac{1 - \ln x}{x^{2}}\]
Answer
\[\frac{x^{\frac{1}{x}} \left(1 - \ln\left(x\right)\right)}{x^{2}}\]

f rises steeply out of the origin, rounds over a broad hump and then drifts slowly back down toward 1.

Zero at \(x = e\): the maximum of \(x^{1/x}\), which is why \(e^{1/e}\) beats every other \(x^{1/x}\).

Open x^(1/x) in the calculator
Example 5
\[\frac{d}{dx}\left[\left(x^{2} + 1\right)^{x}\right]\]
  1. \(f = x^{2} + 1\), \(g = x\), so \(g' = 1\) and \(f' = 2x\).

    \[= \left(x^{2} + 1\right)^{x}\left(\ln\left(x^{2} + 1\right) + \frac{2x^{2}}{x^{2} + 1}\right)\]
Answer
\[\left(x^{2} + 1\right)^{x} \left(\ln\left(x^{2} + 1\right) + \frac{2 x^{2}}{x^{2} + 1}\right)\]

f decays toward zero on the left and climbs steeply on the right, with f′ positive throughout.

Both terms are positive here, so the function is increasing for \(x > 0\).

Open (x^2+1)^x in the calculator

Watch out for

  • Do not use the power rule on \(x^{x}\); the exponent is not constant.
  • Do not use the exponential rule either; the base is not constant.
  • Remember to multiply back by \(y\) at the end — the logarithm step gives \(\frac{y'}{y}\), not \(y'\).