Logarithmic differentiation
When a function is a product of many factors, or has the form u v u^v u v where both u u u and v v v depend on x x x , taking the natural logarithm before differentiating simplifies the calculation dramatically. The trick: log ( u v ) = log u + log v \log(uv) = \log u + \log v log ( uv ) = log u + log v converts multiplication into addition, and log ( u v ) = v log u \log(u^v) = v \log u log ( u v ) = v log u separates the exponent from the base.
The procedure
To differentiate y = f ( x ) y = f(x) y = f ( x ) logarithmically:
Take log \log log of both sides: log y = log f ( x ) \log y = \log f(x) log y = log f ( x ) .
Differentiate using implicit differentiation: 1 y d y d x = d d x [ log f ( x ) ] \dfrac{1}{y}\dfrac{dy}{dx} = \dfrac{d}{dx}[\log f(x)] y 1 d x d y = d x d [ log f ( x )] .
Solve: d y d x = y ⋅ d d x [ log f ( x ) ] = f ( x ) ⋅ d d x [ log f ( x ) ] \dfrac{dy}{dx} = y \cdot \dfrac{d}{dx}[\log f(x)] = f(x) \cdot \dfrac{d}{dx}[\log f(x)] d x d y = y ⋅ d x d [ log f ( x )] = f ( x ) ⋅ d x d [ log f ( x )] .
When to use it
The technique is essential when:
The function is f ( x ) g ( x ) f(x)^{g(x)} f ( x ) g ( x ) , neither pure power rule nor pure exponential applies.
The function is a long product/quotient: log \log log turns the product into a sum.
Worked example: x x x^x x x
Let y = x x y = x^x y = x x . Take log \log log : log y = x log x \log y = x \log x log y = x log x . Differentiate: 1 y d y d x = log x + 1 \dfrac{1}{y} \dfrac{dy}{dx} = \log x + 1 y 1 d x d y = log x + 1 . So d y d x = x x ( log x + 1 ) \dfrac{dy}{dx} = x^x (\log x + 1) d x d y = x x ( log x + 1 ) .
( sin x ) cos x (\sin x)^{\cos x} ( sin x ) c o s x
log y = cos x ⋅ log ( sin x ) \log y = \cos x \cdot \log(\sin x) log y = cos x ⋅ log ( sin x ) . Differentiate: 1 y d y d x = − sin x ⋅ log ( sin x ) + cos x ⋅ cos x sin x = − sin x log ( sin x ) + cot x cos x \dfrac{1}{y}\dfrac{dy}{dx} = -\sin x \cdot \log(\sin x) + \cos x \cdot \dfrac{\cos x}{\sin x} = -\sin x \log(\sin x) + \cot x \cos x y 1 d x d y = − sin x ⋅ log ( sin x ) + cos x ⋅ sin x cos x = − sin x log ( sin x ) + cot x cos x .
So d y d x = ( sin x ) cos x [ − sin x log ( sin x ) + cot x cos x ] \dfrac{dy}{dx} = (\sin x)^{\cos x}\big[-\sin x \log(\sin x) + \cot x \cos x\big] d x d y = ( sin x ) c o s x [ − sin x log ( sin x ) + cot x cos x ] .
A product example
Differentiate y = ( x + 1 ) 2 ( 2 x − 1 ) 3 ( x 2 + 1 ) 4 y = \dfrac{(x + 1)^2 (2x - 1)^3}{(x^2 + 1)^4} y = ( x 2 + 1 ) 4 ( x + 1 ) 2 ( 2 x − 1 ) 3 .
log y = 2 log ( x + 1 ) + 3 log ( 2 x − 1 ) − 4 log ( x 2 + 1 ) \log y = 2 \log(x + 1) + 3 \log(2x - 1) - 4 \log(x^2 + 1) log y = 2 log ( x + 1 ) + 3 log ( 2 x − 1 ) − 4 log ( x 2 + 1 ) .
Differentiate: 1 y d y d x = 2 x + 1 + 6 2 x − 1 − 8 x x 2 + 1 \dfrac{1}{y}\dfrac{dy}{dx} = \dfrac{2}{x + 1} + \dfrac{6}{2x - 1} - \dfrac{8x}{x^2 + 1} y 1 d x d y = x + 1 2 + 2 x − 1 6 − x 2 + 1 8 x .
So d y d x = y [ 2 x + 1 + 6 2 x − 1 − 8 x x 2 + 1 ] \dfrac{dy}{dx} = y\left[\dfrac{2}{x + 1} + \dfrac{6}{2x - 1} - \dfrac{8x}{x^2 + 1}\right] d x d y = y [ x + 1 2 + 2 x − 1 6 − x 2 + 1 8 x ] , with y y y as given.
Worked examples
Example 1. Differentiate y = x sin x y = x^{\sin x} y = x s i n x .
log y = sin x log x \log y = \sin x \log x log y = sin x log x . 1 y d y d x = cos x log x + sin x x \dfrac{1}{y}\dfrac{dy}{dx} = \cos x \log x + \dfrac{\sin x}{x} y 1 d x d y = cos x log x + x sin x . So d y d x = x sin x ( cos x log x + sin x x ) \dfrac{dy}{dx} = x^{\sin x}\left(\cos x \log x + \dfrac{\sin x}{x}\right) d x d y = x s i n x ( cos x log x + x sin x ) .
Example 2. Differentiate y = ( log x ) x y = (\log x)^x y = ( log x ) x .
log y = x log ( log x ) \log y = x \log(\log x) log y = x log ( log x ) . 1 y d y d x = log ( log x ) + x ⋅ 1 / x log x = log ( log x ) + 1 log x \dfrac{1}{y}\dfrac{dy}{dx} = \log(\log x) + x \cdot \dfrac{1/x}{\log x} = \log(\log x) + \dfrac{1}{\log x} y 1 d x d y = log ( log x ) + x ⋅ log x 1/ x = log ( log x ) + log x 1 . So d y d x = ( log x ) x [ log ( log x ) + 1 log x ] \dfrac{dy}{dx} = (\log x)^x\left[\log(\log x) + \dfrac{1}{\log x}\right] d x d y = ( log x ) x [ log ( log x ) + log x 1 ] .
Example 3. If y x = x y y^x = x^y y x = x y , find d y d x \dfrac{dy}{dx} d x d y .
Take log \log log : x log y = y log x x \log y = y \log x x log y = y log x . Differentiate: log y + x y d y d x = d y d x log x + y x \log y + \dfrac{x}{y}\dfrac{dy}{dx} = \dfrac{dy}{dx}\log x + \dfrac{y}{x} log y + y x d x d y = d x d y log x + x y . Solve: d y d x ( x y − log x ) = y x − log y \dfrac{dy}{dx}\left(\dfrac{x}{y} - \log x\right) = \dfrac{y}{x} - \log y d x d y ( y x − log x ) = x y − log y . So d y d x = y ( y − x log y ) x ( x − y log x ) \dfrac{dy}{dx} = \dfrac{y(y - x \log y)}{x(x - y \log x)} d x d y = x ( x − y log x ) y ( y − x log y ) after multiplying through.
Example 4. Differentiate y = x x + x 1 / x y = x^x + x^{1/x} y = x x + x 1/ x .
Each term needs logarithmic differentiation.
u = x x u = x^x u = x x : d u d x = x x ( log x + 1 ) \dfrac{du}{dx} = x^x(\log x + 1) d x d u = x x ( log x + 1 ) .
v = x 1 / x v = x^{1/x} v = x 1/ x : log v = log x x \log v = \dfrac{\log x}{x} log v = x log x . 1 v d v d x = 1 − log x x 2 \dfrac{1}{v}\dfrac{dv}{dx} = \dfrac{1 - \log x}{x^2} v 1 d x d v = x 2 1 − log x . So d v d x = x 1 / x ⋅ 1 − log x x 2 \dfrac{dv}{dx} = x^{1/x} \cdot \dfrac{1 - \log x}{x^2} d x d v = x 1/ x ⋅ x 2 1 − log x .
d y d x = x x ( log x + 1 ) + x 1 / x ⋅ 1 − log x x 2 \dfrac{dy}{dx} = x^x(\log x + 1) + x^{1/x} \cdot \dfrac{1 - \log x}{x^2} d x d y = x x ( log x + 1 ) + x 1/ x ⋅ x 2 1 − log x .
Example 5. Differentiate y = ( x − 1 ) ( x − 2 ) ( x − 3 ) ( x − 4 ) y = \sqrt{\dfrac{(x - 1)(x - 2)}{(x - 3)(x - 4)}} y = ( x − 3 ) ( x − 4 ) ( x − 1 ) ( x − 2 ) .
log y = 1 2 [ log ( x − 1 ) + log ( x − 2 ) − log ( x − 3 ) − log ( x − 4 ) ] \log y = \tfrac{1}{2}[\log(x - 1) + \log(x - 2) - \log(x - 3) - \log(x - 4)] log y = 2 1 [ log ( x − 1 ) + log ( x − 2 ) − log ( x − 3 ) − log ( x − 4 )] .
1 y d y d x = 1 2 [ 1 x − 1 + 1 x − 2 − 1 x − 3 − 1 x − 4 ] \dfrac{1}{y}\dfrac{dy}{dx} = \tfrac{1}{2}\left[\dfrac{1}{x - 1} + \dfrac{1}{x - 2} - \dfrac{1}{x - 3} - \dfrac{1}{x - 4}\right] y 1 d x d y = 2 1 [ x − 1 1 + x − 2 1 − x − 3 1 − x − 4 1 ] .
So d y d x = y 2 [ 1 x − 1 + 1 x − 2 − 1 x − 3 − 1 x − 4 ] \dfrac{dy}{dx} = \dfrac{y}{2}\left[\dfrac{1}{x - 1} + \dfrac{1}{x - 2} - \dfrac{1}{x - 3} - \dfrac{1}{x - 4}\right] d x d y = 2 y [ x − 1 1 + x − 2 1 − x − 3 1 − x − 4 1 ] .
Example 6. Differentiate y = x x x y = x^{x^x} y = x x x .
y = x u y = x^{u} y = x u where u = x x u = x^x u = x x . log y = u log x = x x log x \log y = u \log x = x^x \log x log y = u log x = x x log x .
1 y d y d x = d d x ( x x log x ) = ( x x ( log x + 1 ) ) log x + x x ⋅ 1 x = x x [ ( log x ) 2 + log x + 1 / x ] \dfrac{1}{y}\dfrac{dy}{dx} = \dfrac{d}{dx}(x^x \log x) = (x^x(\log x + 1)) \log x + x^x \cdot \dfrac{1}{x} = x^x[(\log x)^2 + \log x + 1/x] y 1 d x d y = d x d ( x x log x ) = ( x x ( log x + 1 )) log x + x x ⋅ x 1 = x x [( log x ) 2 + log x + 1/ x ] .
So d y d x = x x x ⋅ x x [ ( log x ) 2 + log x + 1 x ] \dfrac{dy}{dx} = x^{x^x} \cdot x^x \left[(\log x)^2 + \log x + \dfrac{1}{x}\right] d x d y = x x x ⋅ x x [ ( log x ) 2 + log x + x 1 ] .
Try it yourself
Differentiate y = x x y = x^x y = x x .
Differentiate y = ( x 2 + 1 ) x y = (x^2 + 1)^x y = ( x 2 + 1 ) x .
Differentiate y = x sin x y = x^{\sin x} y = x s i n x .
Differentiate y = ( 2 x + 1 ) 3 ( 3 x − 1 ) 2 ( x + 2 ) y = \dfrac{(2x + 1)^3}{(3x - 1)^2 (x + 2)} y = ( 3 x − 1 ) 2 ( x + 2 ) ( 2 x + 1 ) 3 using log differentiation.
If y = ( 1 + x ) ( 1 + x 2 ) ( 1 + x 4 ) y = (1 + x)(1 + x^2)(1 + x^4) y = ( 1 + x ) ( 1 + x 2 ) ( 1 + x 4 ) , differentiate using logs.
Differentiate y = x x x y = \sqrt{x \sqrt{x \sqrt{x}}} y = x x x .
Differentiate y = x x x y = x^{x^x} y = x x x .
Differentiate y = ( sin x ) x y = (\sin x)^x y = ( sin x ) x .
Differentiate y = ( sin x ) sin x y = (\sin x)^{\sin x} y = ( sin x ) s i n x .
Differentiate y = x log x y = x^{\log x} y = x l o g x .
Differentiate y = ( log x ) sin x y = (\log x)^{\sin x} y = ( log x ) s i n x .
If x y ⋅ y x = ( x + y ) x + y x^y \cdot y^x = (x + y)^{x + y} x y ⋅ y x = ( x + y ) x + y , set up the log derivative (do not solve).
Differentiate y = ( 1 + tan x ) x y = (1 + \tan x)^x y = ( 1 + tan x ) x .
Differentiate y = e 2 x ( x − 1 ) 2 x x + 1 y = \dfrac{e^{2x}(x - 1)^2}{x \sqrt{x + 1}} y = x x + 1 e 2 x ( x − 1 ) 2 using logs.
Pitfalls / Tricks
log \log log of a product becomes a sum , that is the whole point of log differentiation.
Always restate the original y y y when writing the final d y / d x dy/dx d y / d x .
For functions like x x x^x x x where both base and exponent depend on x x x , neither plain power rule nor plain exponential rule works. Log first.
For products of more than three factors, log differentiation saves enormous time.
Watch for domain issues: log f ( x ) \log f(x) log f ( x ) requires f ( x ) > 0 f(x) > 0 f ( x ) > 0 .
Next, parametric and higher-order derivatives.