Calculus · Grade 12 and undergraduate

The Chain Rule: Derivatives of Composite Functions

Quick answer

A composite function f(g(x)) has an outer function f and an inner function g. The chain rule says its derivative is f′(g(x)) · g′(x): differentiate the outer function with the inside left alone, then multiply by the derivative of the inside. In Leibniz notation, dy/dx = dy/du · du/dx, because rates of change multiply along a chain like gear ratios. The rule gives the derivatives of [g(x)]^n, e^g(x), sin g(x), ln g(x) and a^x.

What you'll learn

  • Identify the outer and inner functions of a composite
  • Apply the chain rule, in function and Leibniz notation
  • Differentiate powers, exponentials, sines and logarithms of an inner function
  • Apply the chain rule more than once, and differentiate a^x

Functions inside functions

y=(3x2+1)5y = (3x^2 + 1)^5 is a composite: first compute the inner function u=3x2+1u = 3x^2 + 1, then apply the outer function y=u5y = u^5. So are e−x2e^{-x^2}, sin⁡5x\sin 5x and ln⁡(x2+1)\ln(x^2 + 1).

None of the rules so far handles these directly, and expanding (3x2+1)5(3x^2 + 1)^5 by hand is no way to live.

The chain rule

If y=f(g(x))y = f(g(x)), then

ddxf(g(x))=f′(g(x))⋅g′(x)\frac{d}{dx} f\big(g(x)\big) = f'\big(g(x)\big) \cdot g'(x)

Differentiate the outer function, leaving the inside untouched, then multiply by the derivative of the inside. With u=g(x)u = g(x), the same rule in Leibniz notation reads

dydx=dydu⋅dudx\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}

Why the rates multiply

Think of three gears. If gear uu turns 33 times for each turn of gear xx, and gear yy turns 22 times for each turn of uu, then yy turns 2⋅3=62 \cdot 3 = 6 times for each turn of xx.

Derivatives are rates, and rates along a chain compound the same way. A small change Δx\Delta x causes a change Δu≈g′(x) Δx\Delta u \approx g'(x)\,\Delta x in the inner function. That in turn causes Δy≈f′(u) Δu≈f′(u) g′(x) Δx\Delta y \approx f'(u)\,\Delta u \approx f'(u)\,g'(x)\,\Delta x. Each link multiplies the change by its own rate, so the rate through the whole chain is the product of the rates.

Patterns to know

Each row is the chain rule with a familiar outer function:

FunctionDerivative
(g(x))n\big(g(x)\big)^nn(g(x))n−1g′(x)n\big(g(x)\big)^{n - 1} g'(x)
eg(x)e^{g(x)}eg(x) g′(x)e^{g(x)}\,g'(x)
sin⁡g(x)\sin g(x)cos⁡g(x)⋅g′(x)\cos g(x) \cdot g'(x)
cos⁡g(x)\cos g(x)−sin⁡g(x)⋅g′(x)-\sin g(x) \cdot g'(x)
ln⁡g(x)\ln g(x)g′(x)g(x)\tfrac{g'(x)}{g(x)}

And for any base a>0a > 0: since ax=exln⁡aa^x = e^{x \ln a}, the chain rule gives

ddxax=exln⁡a⋅ln⁡a=axln⁡a\frac{d}{dx} a^x = e^{x \ln a} \cdot \ln a = a^x \ln a

Worked examples

Common mistakes

Practice problems

  1. Differentiate y=(4x−7)6y = (4x - 7)^6.

    Answer

    y′=24(4x−7)5y' = 24(4x - 7)^5

    Full solution

    6(4x−7)5⋅4=24(4x−7)56(4x - 7)^5 \cdot 4 = 24(4x - 7)^5.

  2. Differentiate y=x2+9y = \sqrt{x^2 + 9}.

    Answer

    y′=xx2+9y' = \tfrac{x}{\sqrt{x^2 + 9}}

    Full solution

    y=(x2+9)1/2y = (x^2 + 9)^{1/2}, so y′=12(x2+9)−1/2⋅2x=xx2+9y' = \tfrac{1}{2}(x^2 + 9)^{-1/2} \cdot 2x = \tfrac{x}{\sqrt{x^2 + 9}}.

  3. Differentiate y=e3xy = e^{3x} and y=ex3y = e^{x^3}.

    Answer

    3e3x3e^{3x} and 3x2ex33x^2 e^{x^3}

    Full solution

    The inner functions are 3x3x and x3x^3, with derivatives 33 and 3x23x^2.

  4. Differentiate y=cos⁡(4x2−x)y = \cos(4x^2 - x).

    Answer

    y′=−(8x−1)sin⁡(4x2−x)y' = -(8x - 1)\sin(4x^2 - x)

    Full solution

    −sin⁡(4x2−x)⋅(8x−1)-\sin(4x^2 - x) \cdot (8x - 1).

  5. Differentiate y=ln⁡(cos⁡x)y = \ln(\cos x).

    Answer

    y′=−tan⁡xy' = -\tan x

    Full solution

    1cos⁡x⋅(−sin⁡x)=−tan⁡x\tfrac{1}{\cos x} \cdot (-\sin x) = -\tan x.

  6. Differentiate y=5xy = 5^x.

    Answer

    y′=5xln⁡5y' = 5^x \ln 5

    Full solution

    5x=exln⁡55^x = e^{x \ln 5}, so y′=exln⁡5ln⁡5=5xln⁡5y' = e^{x \ln 5} \ln 5 = 5^x \ln 5.

  7. Differentiate y=tan⁡3(2x)y = \tan^3(2x).

    Answer

    y′=6tan⁡2(2x)sec⁡2(2x)y' = 6\tan^2(2x)\sec^2(2x)

    Full solution

    Three links: the cube, the tangent, the 2x2x. 3tan⁡2(2x)⋅sec⁡2(2x)⋅23\tan^2(2x) \cdot \sec^2(2x) \cdot 2.

  8. Differentiate y=x2e−xy = x^2 e^{-x}.

    Answer

    y′=xe−x(2−x)y' = x e^{-x}(2 - x)

    Full solution

    Product rule, with the chain rule for e−xe^{-x}: 2xe−x+x2⋅(−e−x)=xe−x(2−x)2x e^{-x} + x^2 \cdot (-e^{-x}) = x e^{-x}(2 - x).

  9. If f(3)=1f(3) = 1, f′(3)=4f'(3) = 4, g(1)=3g(1) = 3 and g′(1)=2g'(1) = 2, find (f∘g)′(1)(f \circ g)'(1).

    Answer

    88

    Full solution

    (f∘g)′(1)=f′(g(1))⋅g′(1)=f′(3)⋅2=4⋅2=8(f \circ g)'(1) = f'(g(1)) \cdot g'(1) = f'(3) \cdot 2 = 4 \cdot 2 = 8.

  10. A student writes ddx(x2+1)3=3(x2+1)2\tfrac{d}{dx}(x^2 + 1)^3 = 3(x^2 + 1)^2. What went wrong?

    Hint

    What is the derivative of the inside?

    Answer

    The inner derivative is missing. The answer is 6x(x2+1)26x(x^2 + 1)^2.

    Full solution

    The outer derivative 3(x2+1)23(x^2 + 1)^2 must be multiplied by the derivative of x2+1x^2 + 1, which is 2x2x.

    3(x2+1)2⋅2x=6x(x2+1)23(x^2 + 1)^2 \cdot 2x = 6x(x^2 + 1)^2.

Frequently asked questions

What is the chain rule?

The derivative of f(g(x)) is f′(g(x)) · g′(x): the derivative of the outer function, evaluated at the inner one, times the derivative of the inner function.

How do I spot a composite function?

Look for something other than plain x inside a function: a power of (3x + 1), e raised to −x², the sine of 5x. The something is the inner function.

Why do the derivatives multiply?

Rates of change compound. If u changes 3 times as fast as x, and y changes 2 times as fast as u, then y changes 6 times as fast as x.

What is the derivative of a^x?

a^x ln a. Write a^x = e^(x ln a) and apply the chain rule.

What is the derivative of ln(g(x))?

g′(x)/g(x). For example, the derivative of ln(x² + 1) is 2x/(x² + 1).

What to learn next