Tutorials › Calculus I › Differentiating x Raised to a Function

Exponential and Logarithmic Derivatives · Tutorial 545 of 1495

Differentiating x Raised to a Function

Derive d/dx of x^g(x) for x>0 by taking logarithms, and see it as a power-rule term plus an exponential-rule term.

Intermediate 9 min read

What You'll Learn

  • Recognize when both the base and exponent depend on x.
  • Derive d/dx x^g(x) = x^g(x)(g'(x) ln x + g(x)/x) by logarithmic differentiation.
  • Differentiate x^(x^2), x^(sin x) and x^(2x+1).
  • Interpret the result as a power-rule part plus an exponential-rule part.
  • Avoid applying the power rule or exponential rule alone.

When Neither the Power Rule nor the Exponential Rule Applies

The Power Rule differentiates \(x^n\) when the exponent \(n\) is a constant, and the exponential rule differentiates \(b^x\) when the base \(b\) is a constant. A function such as \(x^{x^2}\) or \(x^{\sin x}\) breaks both rules, because the base and the exponent are both functions of \(x\). The tool for this situation is logarithmic differentiation: take the natural logarithm, which turns the exponent into a factor, then differentiate implicitly. The earlier tutorial applied this idea to \(x^x\). Here the exponent is replaced by a general differentiable function \(g(x)\).

Throughout, \(x>0\), so that \(x^{g(x)}=e^{g(x)\ln x}\) is defined for every real exponent and \(\ln x\) exists.

Theorem: Let \(g\) be differentiable on an interval of positive numbers. Then for \(y=x^{g(x)}\), \(\dfrac{dy}{dx}=x^{g(x)}\left(g'(x)\ln x+\dfrac{g(x)}{x}\right).\)

Derivation by Logarithmic Differentiation

1
Take logarithms.
Since \(y=x^{g(x)}>0\), we may write \(\ln y=g(x)\ln x\).
2
Differentiate both sides.
The left side is \(\dfrac{y'}{y}\) by the Chain Rule. The right side is a product, so the Product Rule gives \(g'(x)\ln x+g(x)\cdot\dfrac1x\).
3
Solve for \(y'\).
Multiply by \(y=x^{g(x)}\): \(y'=x^{g(x)}\left(g'(x)\ln x+\dfrac{g(x)}{x}\right)\).

The two terms in the parentheses have a clear meaning. If the exponent were frozen at a constant \(n\), the Power Rule would give \(n\,x^{n-1}=x^{g}\cdot\dfrac{g}{x}\), which is the second term. If the base were frozen at a constant \(b\), the exponential rule would give \(b^{g}\ln b\cdot g'\), and the first term \(x^{g}\,g'\ln x\) has the same shape with \(b\) replaced by \(x\). The true derivative is the sum of these two contributions, one from letting the exponent vary and one from letting the base vary.

Worked Example: A Polynomial Exponent

Differentiate \(y=x^{x^2}\) for \(x>0\).

Here \(g(x)=x^2\) and \(g'(x)=2x\). The theorem gives

$$ y'=x^{x^2}\left(2x\ln x+\frac{x^2}{x}\right)=x^{x^2}\,x\,(2\ln x+1)=x^{x^2+1}(2\ln x+1). $$

Check at \(x=1\): \(y(1)=1\), and the formula gives \(1^{2}\,(2\cdot0+1)=1\). A difference quotient from \(y(1.001)\approx1.001002\) and \(y(0.999)\approx0.999002\) is about \(1.000\), as predicted.

Worked Example: A Trigonometric Exponent

Differentiate \(y=x^{\sin x}\) for \(x>0\) and evaluate the derivative at \(x=2\).

With \(g(x)=\sin x\) and \(g'(x)=\cos x\),

$$ y'=x^{\sin x}\left(\cos x\,\ln x+\frac{\sin x}{x}\right). $$

At \(x=2\): \(\sin2\approx0.909297\), \(\cos2\approx-0.416147\), \(\ln2\approx0.693147\). Then \(2^{\sin2}\approx1.8781\) and the bracket is \(-0.416147(0.693147)+\dfrac{0.909297}{2}\approx-0.288443+0.454649=0.166206\). So \(y'(2)\approx1.8781\times0.166206\approx0.3121\).

Check: a difference quotient of \(x^{\sin x}\) using \(x=2.001\) and \(x=1.999\) gives a value near \(0.312\).

Worked Example: A Linear Exponent

Differentiate \(y=x^{2x+1}\) and evaluate at \(x=1\).

Here \(g(x)=2x+1\), \(g'(x)=2\), so

$$ y'=x^{2x+1}\left(2\ln x+\frac{2x+1}{x}\right). $$

At \(x=1\), \(\ln1=0\) and \(x^{2x+1}=1\), so \(y'(1)=1\cdot\left(0+3\right)=3\).

Check: \(y(1.001)\approx1.003005\) and \(y(0.999)\approx0.997005\), giving a difference quotient of \(3.000\).

A Consistency Test

Whenever a general formula is derived, test it on a case where the answer is already known. Take the constant exponent \(g(x)=3\). Then \(g'(x)=0\) and the theorem gives \(y'=x^{3}\left(0\cdot\ln x+\dfrac3x\right)=3x^{2}\), the ordinary Power Rule. For \(g(x)=x\) it gives \(x^x(\ln x+1)\), the result from the previous tutorial. A formula that fails such tests has an error.

Common Mistakes

Using only the Power Rule. Applying \(g\,x^{g-1}\) to \(x^{x^2}\) would give \(x^2\cdot x^{x^2-1}=x^{x^2+1}\). At \(x=2\) this is \(2^5=32\), while the correct derivative is \(2^{5}(2\ln2+1)\approx76.3\). The missing factor is the part coming from the variable exponent.

Using only the exponential rule. Writing \(\dfrac{d}{dx}x^{g}=x^{g}\,g'\ln x\) leaves out the Power Rule contribution \(g\,x^{g-1}\). For \(g(x)=3\), it would give \(0\) instead of \(3x^2\).

Forgetting the domain. The logarithm step needs \(x>0\). For negative \(x\), \(x^{g(x)}\) is generally not defined for non-integer exponents, so the formula should not be applied there.

Worked Example: A Derivative That Vanishes

Find where \(y=x^{1/x}\) is increasing and decreasing for \(x>0\).

From the practice formula with \(g(x)=\dfrac1x\) and \(g'(x)=-\dfrac1{x^2}\),

$$ y'=x^{1/x}\left(-\frac{\ln x}{x^2}+\frac{1}{x^2}\right)=x^{1/x-2}\,(1-\ln x). $$

The factor \(x^{1/x-2}\) is positive for \(x>0\), so the sign of \(y'\) is the sign of \(1-\ln x\). It is positive for \(0<x<e\), zero at \(x=e\), and negative for \(x>e\). The function increases up to \(x=e\) and then decreases, so its maximum is \(e^{1/e}\approx1.4447\).

Check: \(1.5^{1/1.5}\approx1.3104\), \(e^{1/e}\approx1.4447\) and \(4^{1/4}\approx1.4142\), consistent with a peak at \(x=e\).

Summary of the Rule

SituationDerivativeMethod
\(x^n\), \(n\) constant\(n\,x^{n-1}\)Power Rule
\(b^{x}\), \(b\) constant\(b^x\ln b\)Exponential rule
\(x^{g(x)}\), \(x>0\)\(x^{g}\left(g'\ln x+\dfrac gx\right)\)Logarithmic differentiation

The third row contains the first two as special cases, which is the best way to remember it: freezing the exponent recovers the Power Rule term, and freezing the base recovers the exponential-rule term. When a problem has this form, the procedure is always the same: take logarithms, differentiate implicitly, multiply back by the original function, and simplify. State \(x>0\) at the start, because the argument depends on it.

Worked Example: A Tangent Line Estimate

Use the derivative of \(y=x^{2x+1}\) at \(x=1\) to estimate \(1.05^{3.1}\).

From the earlier example, \(y(1)=1\) and \(y'(1)=3\). The tangent line is \(y=1+3(x-1)=3x-2\). At \(x=1.05\) the exponent is \(2(1.05)+1=3.1\), so

$$ 1.05^{3.1}=y(1.05)\approx3(1.05)-2=1.15. $$

Check: the exact value is \(1.05^{3.1}\approx1.16329\). The tangent-line estimate is slightly low, which means the curve bends upward there, a feature that the first derivative alone cannot show.

It is worth seeing why the answer is not simply the sum of two independent pieces. The change in \(x^{g(x)}\) when \(x\) moves comes from two sources at once: the base changes, which affects the power through the Power Rule, and the exponent changes, which affects the power through the exponential rule. For small changes these effects add, and that is exactly the sum inside the parentheses. This reasoning is the same one used in multivariable calculus to differentiate a function of two variables along a path, and it explains why the formula contains both a \(\ln x\) term and a \(\frac1x\) term.

Where This Fits in the Course

This tutorial belongs to the module “Exponential and Logarithmic Derivatives”. The tutorial just before it is “Differentiating x to the x,” and the one that follows is “Differentiating a Function Raised to Another Function.”

A Second Route: Rewrite as an Exponential

Logarithmic differentiation can be replaced by a rewrite. For \(x>0\), \(x^{g(x)}=e^{g(x)\ln x}\), so the Chain Rule applied to the exponential gives

$$ \frac{d}{dx}e^{g(x)\ln x}=e^{g(x)\ln x}\cdot\frac{d}{dx}\bigl(g(x)\ln x\bigr)=x^{g(x)}\left(g'(x)\ln x+\frac{g(x)}{x}\right), $$

the same formula. For \(g(x)=x^2\), the derivative of the exponent is \(\dfrac{d}{dx}(x^2\ln x)=2x\ln x+x\), so \(\dfrac{d}{dx}x^{x^2}=x^{x^2}(2x\ln x+x)\), matching the first worked example. Having two routes to the same answer is a useful check on any individual calculation.

Practice Problems with Answers

Try each problem before reading the answer. Each answer below was verified by differentiation or by evaluating a difference quotient or integral numerically.

  1. Differentiate \(x^{3x}\) for \(x>0\).
    Answer. \(x^{3x}(3\ln x+3)\).
  2. Differentiate \(x^{\cos x}\) and evaluate at \(x=1\).
    Answer. \(x^{\cos x}\left(-\sin x\ln x+\dfrac{\cos x}{x}\right)\); at \(x=1\) this is \(\cos1\approx0.5403\).
  3. Differentiate \(x^{\ln x}\).
    Answer. Since \(x^{\ln x}=e^{(\ln x)^2}\), the derivative is \(x^{\ln x}\cdot\dfrac{2\ln x}{x}\). The general formula agrees: \(x^{\ln x}\left(\dfrac{\ln x}{x}+\dfrac{\ln x}{x}\right)\).
  4. Show that \(x^{1/x}\) has a critical point at \(x=e\).
    Answer. With \(g=1/x\) and \(g'=-1/x^2\): \(\dfrac{d}{dx}x^{1/x}=x^{1/x-2}(1-\ln x)\), which is zero when \(\ln x=1\).

Check Your Understanding

Work these without looking back, then confirm each answer with a difference quotient.

  1. Differentiate \(x^{3x}\) for \(x>0\).
  2. Find the derivative of \(x^{\cos x}\) and evaluate it at \(x=1\).
  3. Show that the general formula reduces to the Power Rule when \(g(x)=n\) is constant.
  4. Differentiate \(x^{\ln x}\) and simplify the result.
  5. Explain which part of \(x^{g}(g'\ln x+g/x)\) comes from the variable exponent and which from the variable base.

Test yourself: Calculus I final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon