practicecalculus
Derivatives

Logarithmic Differentiation: Step by Step, With Examples

Learn logarithmic differentiation step by step: how to differentiate x^x, variable exponents and messy products or quotients, with worked examples.

By the PracticeCalculus team Published 8 min read

Share

X LinkedIn Facebook WhatsApp Reddit Email

Try it yourself

What is $\dfrac{d}{dx}\left(y^3\right)$?
Practice more like this →
On this page
  1. What is logarithmic differentiation?
  2. The 4-step method for logarithmic differentiation
  3. Worked example 1: the derivative of x^x
  4. Worked example 2: a trig function in the exponent
  5. Worked example 3: a function raised to a function
  6. Worked example 4: a messy product and quotient
  7. What about negative values? The absolute value fix
  8. Logarithmic differentiation vs rewriting with e
  9. When should you use logarithmic differentiation?
  10. Common mistakes with logarithmic differentiation
  11. Quick reference: common logarithmic derivatives
  12. Practice until the four steps are automatic

You know how to differentiate x^5 and you know how to differentiate 5^x. Then your homework asks for the derivative of x^x, and neither rule seems to fit. Logarithmic differentiation is the tool built for exactly this moment, and it also turns ugly products and quotients into easy sums.

This guide explains what logarithmic differentiation is, gives you a four-step method you can apply every time, and walks through worked examples line by line.

What is logarithmic differentiation?

Logarithmic differentiation is a technique where you take the natural logarithm of both sides of y = f(x) before differentiating. The log laws break the function into simpler pieces, then you differentiate implicitly and solve for y'.

It works because of one key derivative. By the chain rule, differentiating \ln y with respect to x gives

\frac{d}{dx}\ln y = \frac{1}{y}\cdot\frac{dy}{dx} = \frac{y'}{y}

So if you can find \frac{y'}{y}, you multiply by y and you are done:

y' = y \cdot \frac{d}{dx}\bigl[\ln y\bigr]

The whole method rests on three log laws, which do the simplifying for you:

Log law What it does
\ln(ab) = \ln a + \ln b turns products into sums
\ln\left(\frac{a}{b}\right) = \ln a - \ln b turns quotients into differences
\ln(a^n) = n\ln a brings exponents down as multipliers

That last law is the star of the show. It pulls a variable exponent down to the ground where ordinary rules can reach it.

The 4-step method for logarithmic differentiation

  1. Take ln of both sides. Write \ln y = \ln f(x).
  2. Expand with log laws. Break products, quotients and powers apart until there are no logs of products left.
  3. Differentiate both sides. The left side becomes \frac{y'}{y}. The right side uses the usual rules.
  4. Multiply by y and substitute. Solve for y' and replace y with the original function.

This is the procedure summarized on the logarithmic differentiation rule page. Let us see it in action.

Worked example 1: the derivative of x^x

Find \frac{dy}{dx} for y = x^x, with x > 0.

Step 1. Take ln of both sides.

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

Step 2. Expand. The power law brings the exponent down:

\ln y = x\ln x

Step 3. Differentiate both sides. The left side is \frac{y'}{y}. The right side is a product, so use the product rule with u = x and v = \ln x:

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

Step 4. Multiply by y and substitute.

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

Check it with a point: at x = 1, y' = 1^1(\ln 1 + 1) = 1. So the tangent line at (1, 1) is y = x. Also, y' = 0 when \ln x = -1, which means x = \frac{1}{e}. That is where the graph bottoms out.

Graph of y = x^x with its tangent line at x = 1 and minimum at x = 1/e
The slope of x^x is x^x(\ln x + 1). It equals 1 at x = 1 and 0 at x = \frac{1}{e} \approx 0.368, the minimum point.

You can compare this result with the reference page for the derivative of x^x.

Tip: Notice that x^x(\ln x + 1) = x^x\ln x + x\cdot x^{x-1}. The first term is what the exponential rule would give, and the second is what the power rule would give. The true answer is the sum of both, because both the base and the exponent are changing.

Worked example 2: a trig function in the exponent

Find \frac{dy}{dx} for y = x^{\sin x}, with x > 0.

Step 1. \ln y = \ln\left(x^{\sin x}\right).

Step 2. Bring the exponent down:

\ln y = \sin x \cdot \ln x

Step 3. Differentiate. The right side is again a product, with u = \sin x and v = \ln x:

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

Step 4. Multiply by y:

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

The pattern is the same every time a variable sits in the exponent: the log turns the problem into a product rule problem.

Worked example 3: a function raised to a function

Find y' for y = (x^2 + 1)^x, then evaluate it at x = 1.

Step 1. \ln y = \ln\left((x^2+1)^x\right).

Step 2. Power law:

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

Step 3. Product rule on the right, plus the chain rule for \ln(x^2+1), whose derivative is \frac{2x}{x^2+1}:

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

Step 4. Multiply by y:

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

At x = 1: y = 2^1 = 2, \ln(2) stays as is, and \frac{2(1)}{2} = 1. So

y'(1) = 2(\ln 2 + 1) \approx 3.386

Worked example 4: a messy product and quotient

Logarithmic differentiation is not only for variable exponents. Consider

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

Using the quotient rule with a product rule inside would be painful. Logs make it a sum.

Step 1. \ln y = \ln\left(\dfrac{(x+1)^2(x+2)^3}{(x+3)^4}\right).

Step 2. Product becomes sum, quotient becomes difference, powers come down:

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

Step 3. Differentiate term by term. Each inside function has derivative 1, so no extra factors appear:

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

Step 4. Multiply by y:

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

Let us evaluate at x = 0 to see how clean the numbers stay. First, y(0) = \frac{1\cdot 8}{81} = \frac{8}{81}. Next,

\frac{2}{1} + \frac{3}{2} - \frac{4}{3} = \frac{12}{6} + \frac{9}{6} - \frac{8}{6} = \frac{13}{6}

So

y'(0) = \frac{8}{81}\cdot\frac{13}{6} = \frac{104}{486} = \frac{52}{243}

Tip: Each factor (x - a)^n contributes exactly \frac{n}{x-a} to \frac{y'}{y}, with a minus sign if it lives in the denominator. Once you see this, you can write Step 3 almost instantly.

What about negative values? The absolute value fix

You cannot take the log of a negative number, so what happens when y is negative, as in Example 4 for some values of x? The fix is to use \ln\lvert y \rvert. Since

\frac{d}{dx}\ln\lvert y \rvert = \frac{y'}{y}

holds whenever y \neq 0, every step and the final formula are unchanged. The answer you get with plain \ln y is still correct wherever y is defined and nonzero. For functions like x^x, however, the domain itself is restricted to x > 0, because a variable base with a variable exponent is only defined that way in calculus.

Logarithmic differentiation vs rewriting with e

There is a second route for variable exponents: rewrite the function using a = e^{\ln a}. For x^x:

x^x = e^{x\ln x}

Now apply the chain rule to e^u with u = x\ln x:

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

Same answer, as it must be. The two methods are really the same idea in different clothing. Use whichever feels more natural, but for long products and quotients like Example 4, the logarithmic version is clearly easier. For more on derivatives of e^x and \ln x, see derivatives of exponential and log functions.

When should you use logarithmic differentiation?

Reach for it in these situations:

  • Variable base and variable exponent, like x^x, x^{\sin x}, (\ln x)^x or (x^2+1)^x. Here it is essentially required.
  • Products or quotients of three or more factors, especially with powers or roots.
  • Expressions with many roots and powers, like \sqrt[3]{\frac{x^2-1}{x^4+1}}, where the power law flattens everything.

Skip it for simple functions. Differentiating x^4 or \sin x \cdot e^x with logs works, but it is slower than the power rule or a single product rule.

Common mistakes with logarithmic differentiation

  1. Forgetting to multiply by y. After Step 3 you have \frac{y'}{y}, not y'. Writing y' = \ln x + 1 for y = x^x is the most common error by far.
  2. Leaving y in the answer. y' = y(\ln x + 1) is not finished. Replace y with the original function, x^x.
  3. Using the power rule on x^x. Writing \frac{d}{dx}x^x = x\cdot x^{x-1} treats the exponent as a constant. It is not.
  4. Using the exponential rule on x^x. Writing \frac{d}{dx}x^x = x^x\ln x treats the base as a constant. Also wrong, and also only half of the true answer.
  5. Splitting a log of a sum. \ln(x^2 + 1) is not \ln x^2 + \ln 1. Log laws break apart products, not sums. Leave \ln(x^2+1) whole and use the chain rule.
  6. Dropping the chain rule. The derivative of \ln(2x+1) is \frac{2}{2x+1}, not \frac{1}{2x+1}.

The left side deserves special attention: \ln y differentiates to \frac{y'}{y} because y is a function of x. This is the same reasoning used in implicit differentiation.

Quick reference: common logarithmic derivatives

Function \ln y after expanding Derivative y'
x^x x\ln x x^x(\ln x + 1)
x^{\sin x} \sin x\ln x x^{\sin x}\left(\cos x\ln x + \frac{\sin x}{x}\right)
x^{1/x} \frac{\ln x}{x} x^{1/x}\cdot\frac{1 - \ln x}{x^2}
(\ln x)^x x\ln(\ln x) (\ln x)^x\left(\ln(\ln x) + \frac{1}{\ln x}\right)
f(x)^{g(x)} g(x)\ln f(x) f^{g}\left(g'\ln f + \frac{g f'}{f}\right)

The last row is the general formula. You do not need to memorize it: the four-step method produces it automatically every time.

Practice until the four steps are automatic

Logarithmic differentiation feels strange the first time and routine by the tenth. The steps never change: take ln, expand, differentiate, multiply by y. What takes practice is expanding cleanly and remembering that last multiplication. Work through the interactive lesson below, where each problem gives instant feedback and shows you exactly which step went wrong, so the method becomes second nature before your next exam.

Practice it now

Implicit differentiation

Solve real problems on this topic with instant feedback, hints and a step-by-step walkthrough for every answer. Free, no sign-up needed to start.

Practice this lesson

Frequently asked questions

When should you use logarithmic differentiation?

Use it when the variable appears in both the base and the exponent, such as x^x or (\ln x)^x. It is also worth using for products and quotients of three or more factors raised to powers, because logs turn them into simple sums. For ordinary functions like x^3 or e^{2x}, the usual rules are faster.

What is the derivative of x^x?

The derivative of x^x is x^x(\ln x + 1) for x > 0. You get it by writing \ln y = x\ln x, differentiating to get \frac{y'}{y} = \ln x + 1, and multiplying by y = x^x.

Why can't you use the power rule on x^x?

The power rule only works when the exponent is a constant, like x^5. The exponential rule only works when the base is a constant, like 2^x. In x^x both parts vary, so neither rule applies, and logarithmic differentiation handles both at once.

What if the function can be negative?

Take \ln\lvert y \rvert instead of \ln y. Since \frac{d}{dx}\ln\lvert y \rvert = \frac{y'}{y} as well, every step and the final answer stay exactly the same. That is why most textbooks quietly skip the absolute values.

Is logarithmic differentiation the same as implicit differentiation?

It is a special case of it. After taking the log of both sides you have an equation involving \ln y, and you differentiate it implicitly, using the chain rule to get \frac{y'}{y} on the left side.

Written by the PracticeCalculus team

We build interactive calculus lessons and write every page to be clear and correct. Spotted something off? Tell us and we will fix it.