Unit 3, lesson 31

Logarithmic Differentiation

How taking a logarithm before differentiating turns long products and quotients into sums, handles functions like x to the power x, and which sign and domain conditions it needs.

  • Theory part 61
  • Practice part 62
  • Derivatives of Elementary Functions

Theory, part 61

Practice, part 62

Differentiating a product of five factors with the product rule produces five long terms and plenty of room for mistakes. Logarithms turn products into sums and powers into multiples, and sums are easy to differentiate. So it often pays to take the logarithm first, differentiate, and then undo the logarithm at the end.

Key terms

Logarithmic differentiation

Definition Let y=f(x)y = f(x) be differentiable at xx with f(x)≠0f(x) \neq 0. Then

ddxln⁡∣f(x)∣=f′(x)f(x),sof′(x)=f(x)⋅ddxln⁡∣f(x)∣.\frac{d}{dx} \ln \lvert f(x) \rvert = \frac{f'(x)}{f(x)}, \qquad \text{so} \qquad f'(x) = f(x) \cdot \frac{d}{dx} \ln \lvert f(x) \rvert.

Logarithmic differentiation means taking ln⁡∣y∣\ln \lvert y \rvert, simplifying with the laws of logarithms, differentiating with respect to xx, and multiplying the result by yy.

In plain words The quantity y′y\frac{y'}{y} is the relative rate of change of yy. It is often much easier to compute than y′y' itself, and you recover y′y' by multiplying by yy.

Example For y=x5e3xy = x^5 e^{3x} with x≠0x \neq 0, taking logarithms gives ln⁡∣y∣=5ln⁡∣x∣+3x\ln \lvert y \rvert = 5 \ln \lvert x \rvert + 3x. Differentiating gives y′y=5x+3\frac{y'}{y} = \frac{5}{x} + 3, so

y′=x5e3x(5x+3)=(5x4+3x5)e3x.y' = x^5 e^{3x}\left(\frac{5}{x} + 3\right) = (5x^4 + 3x^5)e^{3x}.

The final formula also holds at x=0x = 0, as the product rule confirms.

Products

Definition If y=f1(x)f2(x)⋯fn(x)y = f_1(x) f_2(x) \cdots f_n(x) where each fif_i is differentiable at xx and fi(x)≠0f_i(x) \neq 0, then

y′y=f1′(x)f1(x)+f2′(x)f2(x)+⋯+fn′(x)fn(x).\frac{y'}{y} = \frac{f_1'(x)}{f_1(x)} + \frac{f_2'(x)}{f_2(x)} + \cdots + \frac{f_n'(x)}{f_n(x)}.

In plain words The relative rate of change of a product is the sum of the relative rates of change of its factors.

Example Let y=x(x+1)(x+2)y = x(x + 1)(x + 2) at x=1x = 1. Here y=6y = 6 and

y′y=11+12+13=116,\frac{y'}{y} = \frac{1}{1} + \frac{1}{2} + \frac{1}{3} = \frac{11}{6},

so y′=6⋅116=11y' = 6 \cdot \frac{11}{6} = 11. Expanding gives y=x3+3x2+2xy = x^3 + 3x^2 + 2x and y′=3x2+6x+2y' = 3x^2 + 6x + 2, which is also 1111 at x=1x = 1.

Quotients

Definition Let ff and gg be differentiable at xx with f(x)≠0f(x) \neq 0 and g(x)≠0g(x) \neq 0, and let y=f/gy = f/g. Then near xx

ln⁡∣y∣=ln⁡∣f∣−ln⁡∣g∣,\ln \lvert y \rvert = \ln \lvert f \rvert - \ln \lvert g \rvert,

and at xx

y′y=f′(x)f(x)−g′(x)g(x).\frac{y'}{y} = \frac{f'(x)}{f(x)} - \frac{g'(x)}{g(x)}.

Factors in the denominator contribute with a minus sign, and powers come down as coefficients.

In plain words Division becomes subtraction. A power like (x2+1)2(x^2 + 1)^2 in the denominator just becomes −2ln⁡(x2+1)-2 \ln(x^2 + 1).

Example Take

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

at x=1x = 1, where y=84=2y = \frac{8}{4} = 2. Taking logarithms gives

ln⁡∣y∣=3ln⁡∣x+1∣−2ln⁡(x2+1),\ln \lvert y \rvert = 3 \ln \lvert x + 1 \rvert - 2 \ln(x^2 + 1),

and differentiating gives

y′y=3x+1−4xx2+1=32−2=−12,\frac{y'}{y} = \frac{3}{x + 1} - \frac{4x}{x^2 + 1} = \frac{3}{2} - 2 = -\frac{1}{2},

so y′(1)=2⋅(−12)=−1y'(1) = 2 \cdot \left(-\frac{1}{2}\right) = -1.

Absolute values for nonzero real factors

Definition The real logarithm is defined only for positive numbers, so for a function that may be negative one works with ln⁡∣y∣\ln \lvert y \rvert. The rules

ln⁡∣uv∣=ln⁡∣u∣+ln⁡∣v∣,ln⁡∣uv∣=ln⁡∣u∣−ln⁡∣v∣,ln⁡∣un∣=nln⁡∣u∣\ln \lvert uv \rvert = \ln \lvert u \rvert + \ln \lvert v \rvert, \qquad \ln \left\lvert \frac{u}{v} \right\rvert = \ln \lvert u \rvert - \ln \lvert v \rvert, \qquad \ln \lvert u^n \rvert = n \ln \lvert u \rvert

hold whenever uu and vv are nonzero real numbers and nn is an integer. For a function uu differentiable at xx with u(x)≠0u(x) \neq 0, the derivative of ln⁡∣u∣\ln \lvert u \rvert at xx is u′u\frac{u'}{u}. The resulting formula for y′y' is proved only at points where every factor is nonzero. Points where a factor is zero must be checked separately.

In plain words The absolute value bars let you use the method even where yy is negative, and they disappear from the answer because the derivative of ln⁡∣u∣\ln \lvert u \rvert is u′/uu'/u, with no bars.

Example Let y=x−3x+1y = \frac{x - 3}{x + 1} at x=0x = 0, where y=−3<0y = -3 < 0, so ln⁡y\ln y is undefined there. Use the absolute value instead.

ln⁡∣y∣=ln⁡∣x−3∣−ln⁡∣x+1∣\ln \lvert y \rvert = \ln \lvert x - 3 \rvert - \ln \lvert x + 1 \rvert

Then

y′y=1x−3−1x+1=−13−1=−43,\frac{y'}{y} = \frac{1}{x - 3} - \frac{1}{x + 1} = -\frac{1}{3} - 1 = -\frac{4}{3},

so y′(0)=−3⋅(−43)=4y'(0) = -3 \cdot \left(-\frac{4}{3}\right) = 4. The quotient rule agrees, since y′=4(x+1)2y' = \frac{4}{(x + 1)^2}.

Variable exponents

Definition Let ff and gg be differentiable at xx with f(x)>0f(x) > 0. Wherever f>0f > 0 the function y=f(x)g(x)y = f(x)^{g(x)} is defined as eg(x)ln⁡f(x)e^{g(x) \ln f(x)}, and ff stays positive near xx because it is continuous there. Taking logarithms gives ln⁡y=g(x)ln⁡f(x)\ln y = g(x) \ln f(x), and differentiating gives

y′=f(x)g(x)(g′(x)ln⁡f(x)+g(x)f′(x)f(x)).y' = f(x)^{g(x)} \left( g'(x) \ln f(x) + g(x) \frac{f'(x)}{f(x)} \right).

In plain words When both the base and the exponent change with xx, neither the power rule (fixed exponent) nor the exponential rule (fixed base) applies. Taking a logarithm brings the exponent down where the product rule can handle it.

Example For y=xxy = x^x with x>0x > 0, taking logarithms gives ln⁡y=xln⁡x\ln y = x \ln x, so y′y=ln⁡x+1\frac{y'}{y} = \ln x + 1 and

y′=xx(ln⁡x+1).y' = x^x(\ln x + 1).

At x=2x = 2 this is 4(ln⁡2+1)≈6.7734(\ln 2 + 1) \approx 6.773.

Positive base assumptions

Definition When the exponent varies with xx, the power f(x)g(x)f(x)^{g(x)} is defined as eg(x)ln⁡f(x)e^{g(x) \ln f(x)}, which requires f(x)>0f(x) > 0. The formula for variable exponents therefore applies only on intervals where the base is positive. A negative base has a real power only for some exponents, namely integers and fractions in lowest terms with an odd denominator. For example (−8)1/3=−2(-8)^{1/3} = -2, while (−8)1/2(-8)^{1/2} is not real. Suppose the base is negative at a point and the exponent gg is continuous and not constant on any open interval around that point. Then every such interval contains points where gg is irrational and the base is still negative, so the power is undefined at points arbitrarily close to the point and cannot be differentiated there. The formula with ln⁡f(x)\ln f(x) makes no sense there either.

In plain words Check that the base is positive before you use the formula. If it is not, restrict to an interval where it is.

Example The base of y=(x2+1)xy = (x^2 + 1)^x is always positive, so the formula holds on all of R\mathbb{R}. With ln⁡y=xln⁡(x2+1)\ln y = x \ln(x^2 + 1),

y′=(x2+1)x(ln⁡(x2+1)+2x2x2+1).y' = (x^2 + 1)^x \left( \ln(x^2 + 1) + \frac{2x^2}{x^2 + 1} \right).

At x=1x = 1 this is 2(ln⁡2+1)≈3.3862(\ln 2 + 1) \approx 3.386. In contrast, xxx^x cannot be differentiated at any x<0x < 0. It has real values at some negative points, such as (−1)−1=−1(-1)^{-1} = -1, but not at others arbitrarily close to them, such as x=−12x = -\frac{1}{2}, where (−12)−1/2\left(-\frac{1}{2}\right)^{-1/2} is not a real number.

Check yourself

  1. Differentiate y=xsin⁡xy = x^{\sin x} for x>0x > 0.
Show the answer

Taking logarithms gives ln⁡y=sin⁡xln⁡x\ln y = \sin x \ln x, so y′y=cos⁡xln⁡x+sin⁡xx\frac{y'}{y} = \cos x \ln x + \frac{\sin x}{x} and

y′=xsin⁡x(cos⁡xln⁡x+sin⁡xx).y' = x^{\sin x}\left(\cos x \ln x + \frac{\sin x}{x}\right).
  1. Let y=x2(x−1)3(x+2)y = x^2 (x - 1)^3 (x + 2). Use logarithmic differentiation to find y′(2)y'(2).
Show the answer

At x=2x = 2 the value is y=4⋅1⋅4=16y = 4 \cdot 1 \cdot 4 = 16, and the relative rate is

y′y=2x+3x−1+1x+2=1+3+14=174.\frac{y'}{y} = \frac{2}{x} + \frac{3}{x - 1} + \frac{1}{x + 2} = 1 + 3 + \frac{1}{4} = \frac{17}{4}.

So y′(2)=16⋅174=68y'(2) = 16 \cdot \frac{17}{4} = 68.

  1. Why do we write ln⁡∣y∣\ln \lvert y \rvert rather than ln⁡y\ln y for y=x−3x+1y = \frac{x - 3}{x + 1} near x=0x = 0?
Show the answer

Near x=0x = 0 the value of yy is negative (it is −3-3 at x=0x = 0), and ln⁡\ln of a negative number is undefined. The absolute value makes the logarithm defined, and the derivative of ln⁡∣u∣\ln \lvert u \rvert is still u′u\frac{u'}{u}.

How this lesson connects