Chain Rule

The rule

The chain rule differentiates a composite function, one function applied to the output of another. If y=f(g(x))y = f(g(x)), then

dydx=f′(g(x))⋅g′(x)\dfrac{dy}{dx} = f'(g(x)) \cdot g'(x)

In words: differentiate the outer function (leaving the inner function alone), then multiply by the derivative of the inner function.

The same rule in Leibniz notation

Naming the inner function makes the rule easier to apply. If y=f(u)y = f(u) and u=g(x)u = g(x), then:

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

It reads as if the dudu terms cancel. They don't really cancel, but it's a reliable way to remember which derivative goes where, and it extends to longer chains: dydx=dydv⋅dvdu⋅dudx\dfrac{dy}{dx} = \dfrac{dy}{dv}\cdot\dfrac{dv}{du}\cdot\dfrac{du}{dx}.

Common chain-rule patterns

Each standard derivative, with the inner function's derivative multiplied on
FunctionDerivative
[g(x)]n[g(x)]^nn[g(x)]n−1⋅g′(x)n[g(x)]^{n-1}\cdot g'(x)
eg(x)e^{g(x)}eg(x)⋅g′(x)e^{g(x)}\cdot g'(x)
ln⁡g(x)\ln g(x)g′(x)g(x)\dfrac{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)
tan⁡g(x)\tan g(x)sec⁡2g(x)⋅g′(x)\sec^2 g(x)\cdot g'(x)

1. Derivative of sin(ln(x))

Find the derivative of f(x)=sin⁡(ln⁡(x))f(x) = \sin(\ln(x)).

Solution: The outer function is sin⁡(u)\sin(u), the inner function is u=ln⁡(x)u = \ln(x). Since ddusin⁡(u)=cos⁡(u)\dfrac{d}{du}\sin(u) = \cos(u) and ddxln⁡(x)=1x\dfrac{d}{dx}\ln(x) = \dfrac{1}{x},

f′(x)=cos⁡(ln⁡(x))⋅1x=cos⁡(ln⁡(x))xf'(x) = \cos(\ln(x)) \cdot \dfrac{1}{x} = \dfrac{\cos(\ln(x))}{x}

2. Derivative of sec(tan(√x))

Find the derivative of sec⁡(tan⁡(x))\sec(\tan(\sqrt{x})) with respect to xx. This nests three functions, so the chain rule is applied twice.

Solution: Let u=xu = \sqrt{x}, v=tan⁡(u)v = \tan(u), and differentiate sec⁡(v)\sec(v) from the outside in:

dudx=12x,dvdu=sec⁡2(u),ddvsec⁡(v)=sec⁡(v)tan⁡(v)\dfrac{du}{dx} = \dfrac{1}{2\sqrt{x}}, \qquad \dfrac{dv}{du} = \sec^2(u), \qquad \dfrac{d}{dv}\sec(v) = \sec(v)\tan(v)

Multiplying the three pieces together (the chain rule again):

12x⋅sec⁡(tan⁡(x))⋅tan⁡(tan⁡(x))⋅sec⁡2(x)\dfrac{1}{2\sqrt{x}} \cdot \sec(\tan(\sqrt{x})) \cdot \tan(\tan(\sqrt{x})) \cdot \sec^2(\sqrt{x})

3. A power of a trig function

Differentiate y=sin⁡3xy = \sin^3 x.

Solution: sin⁡3x\sin^3 x means (sin⁡x)3(\sin x)^3, so the outer function is a cube and the inner function is u=sin⁡xu = \sin x:

dydx=dydu⋅dudx=3u2⋅cos⁡x=3sin⁡2xcos⁡x\dfrac{dy}{dx} = \dfrac{dy}{du}\cdot\dfrac{du}{dx} = 3u^2\cdot\cos x = 3\sin^2 x\cos x

4. A power of a polynomial

Differentiate y=(3x2+1)5y = (3x^2 + 1)^5.

Solution: Expanding the fifth power would be slow. With u=3x2+1u = 3x^2 + 1, dudx=6x\dfrac{du}{dx} = 6x:

dydx=5(3x2+1)4⋅6x=30x(3x2+1)4\dfrac{dy}{dx} = 5(3x^2+1)^4\cdot 6x = 30x(3x^2+1)^4

Common mistakes

  • Forgetting the inner derivative. ddxsin⁡(2x)=2cos⁡(2x)\dfrac{d}{dx}\sin(2x) = 2\cos(2x), not cos⁡(2x)\cos(2x). This is the most common chain-rule error by far.
  • Confusing sin⁡2x\sin^2 x with sin⁡(x2)\sin(x^2). sin⁡2x=(sin⁡x)2\sin^2 x = (\sin x)^2 has derivative 2sin⁡xcos⁡x2\sin x\cos x. sin⁡(x2)\sin(x^2) has derivative 2xcos⁡(x2)2x\cos(x^2).
  • Changing the inside of the outer function. In ddxsin⁡(x2)=cos⁡(x2)⋅2x\dfrac{d}{dx}\sin(x^2) = \cos(x^2)\cdot 2x, the cosine still contains x2x^2. Only the multiplier outside is the inner derivative.
  • Stopping one layer early. In a three-layer chain like sec⁡(tan⁡x)\sec(\tan\sqrt{x}) there are three factors to multiply, one per layer.

Continue learning

Many definite integrals are solved by spotting a chain-rule pattern in reverse, so the two techniques are worth learning back to back.