Logarithmic Differentiation

Logarithmic differentiation is a way to differentiate a function by taking the natural log of both sides first. Log properties turn products, quotients and powers into sums, which are easy to differentiate. It is the standard method for functions like x^x, where the variable is in both the base and the exponent.

Before this lesson: Derivatives of Logarithmic Functions, Implicit Differentiation and Properties of Logarithms

Why taking logs helps

Neither rule you know works on y = x^x. The power rule needs a constant exponent, and the exponential rule needs a constant base. Here both the base and the exponent change.

Logs fix this because they bring exponents down: \ln(x^x) = x\ln x. That is an ordinary product, and the product rule handles it. The same idea turns a long product or quotient into a sum of short logs.

How to use logarithmic differentiation

  1. Take the natural log of both sides: \ln y = \ln(\ldots).
  2. Use log properties to expand the right side into sums and multiples of simpler logs.
  3. Differentiate both sides with respect to x. The left side becomes \frac{y'}{y} (chain rule).
  4. Multiply both sides by y, then replace y with the original function.
\frac{d}{dx}\left[\ln y\right] = \frac{1}{y} \cdot y' = \frac{y'}{y}

Logarithmic differentiation examples

Example 1: The derivative of x^x

Differentiate y = x^x for x \gt 0.

\ln y = \ln\left(x^x\right)

Take the natural log of both sides.

\ln y = x\ln x

Power property: bring the exponent x down.

\frac{y'}{y} = 1 \cdot \ln x + x \cdot \frac{1}{x}

Differentiate both sides; product rule on the right (see product rule).

\frac{y'}{y} = \ln x + 1

Simplify x · 1/x = 1.

y' = y(\ln x + 1)

Multiply both sides by y.

y' = x^x(\ln x + 1)

Replace y with xˣ.

Answer: y' = x^x(\ln x + 1). Notice it is neither x \cdot x^{x-1} (power rule) nor x^x\ln x (exponential rule), but the sum of both.

Graph of y = x^x for x from 0 to 2.2. The curve starts near 1, dips to a lowest point at (1/e, about 0.692), where the tangent line is horizontal, then rises quickly, passing through (1, 1) and (2, 4).
The derivative xˣ(ln x + 1) is 0 when ln x = −1, so xˣ is lowest at x = 1/e ≈ 0.368.

Example 2: Variable base and trig exponent

Differentiate y = x^{\sin x} for x \gt 0.

\ln y = \sin x \ln x

Take the natural log of both sides and bring the exponent down.

\frac{y'}{y} = \cos x \ln x + \sin x \cdot \frac{1}{x}

Differentiate; product rule on the right (see derivatives of trig functions).

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

Multiply both sides by y = x^(sin x).

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

Example 3: A messy quotient

Differentiate y = \frac{x^2(3x + 1)^4}{\sqrt{x^2 + 5}} for x \gt 0.

\ln y = 2\ln x + 4\ln(3x + 1) - \frac{1}{2}\ln(x^2 + 5)

Take ln of both sides. Products become sums, the quotient becomes a difference, and powers come down.

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

Differentiate each log: the derivative of ln u is u′/u.

\frac{y'}{y} = \frac{2}{x} + \frac{12}{3x + 1} - \frac{x}{x^2 + 5}

Simplify each term.

y' = \frac{x^2(3x + 1)^4}{\sqrt{x^2 + 5}}\left(\frac{2}{x} + \frac{12}{3x + 1} - \frac{x}{x^2 + 5}\right)

Multiply both sides by y.

Answer: the last line. Doing this with the quotient, product and chain rules together would take many more steps.

Example 4: Evaluating at a point

Find the slope of y = x^{\sqrt{x}} at x = 4.

\ln y = \sqrt{x}\ln x

Take ln of both sides and bring the exponent down.

\frac{y'}{y} = \frac{1}{2\sqrt{x}}\ln x + \sqrt{x} \cdot \frac{1}{x}

Product rule on the right.

y(4) = 4^{\sqrt{4}} = 4^2 = 16

Find y at x = 4.

\frac{y'}{y} = \frac{\ln 4}{4} + \frac{2}{4}

Substitute x = 4: √4 = 2.

y' = 16\left(\frac{\ln 4}{4} + \frac{1}{2}\right) = 4\ln 4 + 8

Multiply by y = 16.

4\ln 4 + 8 \approx 4(1.386) + 8 \approx 13.55

Use ln 4 ≈ 1.386.

Answer: the slope at x = 4 is 8 + 4\ln 4 \approx 13.55.

Example 5: Word problem with growth rates

A town has 40,000 people, and its population grows 2% per year. The average income per person is $30,000 and grows 3% per year. Total income is I = PA. How fast is total income growing?

\ln I = \ln P + \ln A

Take ln of both sides of I = PA.

\frac{I'}{I} = \frac{P'}{P} + \frac{A'}{A}

Differentiate with respect to time t.

\frac{I'}{I} = 0.02 + 0.03 = 0.05

Each fraction is a growth rate: 2% and 3%.

I = 40000 \cdot 30000 = 1{,}200{,}000{,}000

Find the current total income.

I' = 0.05 \cdot 1{,}200{,}000{,}000 = 60{,}000{,}000

Multiply both sides of the rate equation by I.

Answer: total income grows 5% per year, about $60 million per year right now. Logarithmic differentiation shows that percent growth rates of factors add.

Common mistakes

MistakeExample of the errorFix
Using the power rule on x^x\frac{d}{dx}x^x = x \cdot x^{x-1}The exponent is not constant. Use logs: x^x(\ln x + 1).
Forgetting to multiply by y at the endStopping at y' = \ln x + 1That is y′/y. Multiply by y = xˣ.
Writing d/dx(ln y) as 1/y\frac{d}{dx}\ln y = \frac{1}{y}y depends on x, so the chain rule gives \frac{y'}{y}.
Splitting a log of a sum\ln(x^2 + 5) = \ln x^2 + \ln 5Only products, quotients and powers split.
Taking ln of a negative quantityUsing logs on y = xˣ at x = −2ln y needs y to be positive. When y can be negative, use ln|y|, which has the same derivative.

Related methods

Rewriting with base e

Instead of taking logs, you can write x^x = e^{x\ln x} and use the chain rule: e^{x\ln x}(\ln x + 1) = x^x(\ln x + 1). It is the same calculation in a different order (see derivatives of exponential functions).

When not to use it

For a simple product like x^2\sin x, the product rule is faster. Save logarithmic differentiation for variable exponents and for long products and quotients.

Practice problems

  1. Differentiate y = x^{2x}.
  2. Differentiate y = x^{\ln x}.
  3. Differentiate y = (x + 1)^x.
  4. Differentiate y = x^{1/x}.
  5. Find the slope of y = x^x at x = 1.
  6. Differentiate y = \frac{(x - 1)^3}{(x + 2)^2} with logarithmic differentiation.
  7. Differentiate y = x^4(2x - 1)^3 with logarithmic differentiation.
  8. Differentiate y = (\sin x)^x for 0 \lt x \lt \pi.
  9. Use logarithmic differentiation to show that the derivative of 2^x is 2^x\ln 2.
  10. A rectangle’s length grows 4% per year while its width shrinks 1% per year. At what percent rate is its area changing?
Show answers

1.

\ln y = 2x\ln x

Take ln and bring the exponent down.

\frac{y'}{y} = 2\ln x + 2x \cdot \frac{1}{x} = 2\ln x + 2

Product rule, then simplify.

y' = x^{2x}(2\ln x + 2)

Multiply by y.

Answer: y' = 2x^{2x}(\ln x + 1)

2.

\ln y = \ln x \cdot \ln x = (\ln x)^2

Take ln and bring the exponent down.

\frac{y'}{y} = 2\ln x \cdot \frac{1}{x}

Chain rule on (ln x)².

y' = x^{\ln x} \cdot \frac{2\ln x}{x}

Multiply by y.

Answer: y' = \frac{2\ln x}{x} \cdot x^{\ln x}

3.

\ln y = x\ln(x + 1)

Take ln and bring the exponent down.

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

Product rule.

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

Multiply by y.

Answer: y' = (x + 1)^x\left(\ln(x + 1) + \frac{x}{x + 1}\right)

4.

\ln y = \frac{\ln x}{x}

Take ln: the exponent is 1/x.

\frac{y'}{y} = \frac{1 - \ln x}{x^2}

Quotient rule (see quotient rule).

y' = x^{1/x} \cdot \frac{1 - \ln x}{x^2}

Multiply by y.

Answer: y' = \frac{x^{1/x}(1 - \ln x)}{x^2}

5.

y'(1) = 1^1(\ln 1 + 1)

Use y′ = xˣ(ln x + 1) from Example 1.

y'(1) = 1(0 + 1) = 1

ln 1 = 0.

Answer: 1

6.

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

Take ln; use the quotient and power properties.

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

Differentiate each log.

y' = \frac{(x - 1)^3}{(x + 2)^2}\left(\frac{3}{x - 1} - \frac{2}{x + 2}\right)

Multiply by y.

Answer: the last line

7.

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

Take ln; product and power properties.

\frac{y'}{y} = \frac{4}{x} + \frac{6}{2x - 1}

Differentiate: 3 · 2/(2x − 1).

y' = x^4(2x - 1)^3\left(\frac{4}{x} + \frac{6}{2x - 1}\right)

Multiply by y.

Answer: the last line

8.

\ln y = x\ln(\sin x)

Take ln and bring the exponent down.

\frac{y'}{y} = \ln(\sin x) + x \cdot \frac{\cos x}{\sin x}

Product rule; the derivative of ln(sin x) is cos x / sin x.

y' = (\sin x)^x\left(\ln(\sin x) + x\cot x\right)

Multiply by y; cos x / sin x = cot x.

Answer: y' = (\sin x)^x\left(\ln(\sin x) + x\cot x\right)

9.

\ln y = x\ln 2

Take ln of y = 2ˣ.

\frac{y'}{y} = \ln 2

ln 2 is a constant.

y' = 2^x\ln 2

Multiply by y.

Answer: shown, \frac{d}{dx}2^x = 2^x\ln 2

10.

\ln A = \ln L + \ln W

Take ln of A = LW.

\frac{A'}{A} = \frac{L'}{L} + \frac{W'}{W}

Differentiate with respect to time.

\frac{A'}{A} = 0.04 + (-0.01) = 0.03

Substitute the growth rates.

Answer: the area grows about 3% per year.

Logarithmic differentiation FAQ

When should you use logarithmic differentiation?

Use it when the variable is in both the base and the exponent, like x^x or x^{\sin x}, and for long products and quotients of powers.

What is the derivative of x^x?

\frac{d}{dx}x^x = x^x(\ln x + 1). You get it by taking ln of both sides, which gives \ln y = x\ln x.

Why is d/dx(ln y) equal to y′/y?

y is a function of x, so the chain rule applies: the derivative of ln y is 1/y times y′.

Does logarithmic differentiation work if y is negative?

Use ln|y| instead. Its derivative is still y′/y, so the final answer is the same.

Summary

  • Take ln of both sides, expand with log properties, differentiate, then multiply by y.
  • The left side always becomes \frac{y'}{y}.
  • \frac{d}{dx}x^x = x^x(\ln x + 1).
  • Use it for variable exponents and long products or quotients.
  • Percent growth rates of factors add: \frac{(PA)'}{PA} = \frac{P'}{P} + \frac{A'}{A}.

Previous lesson: Derivatives of Logarithmic Functions

Next lesson: Derivatives of Inverse Trig Functions

Back to the Calculus 1 Index