The Chain Rule

A composition is a chain of links, and each link stretches a small change by its own rate. Build a chain and pick x: the number lines carry an interval through it, the stretches multiply, and as the interval shrinks each approaches its link’s derivative, unless a link squashes the interval flat. Then write dy/dx yourself.

The chain rule dydx=dydu⋅dudx\frac{dy}{dx}=\frac{dy}{du}\cdot\frac{du}{dx}
In function notation (f(g(x)))′=f′(g(x))⋅g′(x)\bigl(f(g(x))\bigr)'=f'\bigl(g(x)\bigr)\cdot g'(x)
Loading interactive simulation...

Lesson

The theory — The Chain Rule

If u = g(x) and y = f(u), the rate of the whole chain is the product of the links' rates, dy/dx = f′(g(x))·g′(x). Each rate is taken where its link is working, so the outer rate is evaluated at u = g(x), not at x. A longer chain multiplies one more rate per link.

What each symbol means

u
the value the inner link hands on, u = g(x)
w
in a three-link chain, the value the middle link hands on

Where the formula comes from

  1. Break the change into links. Move x on by Δx. The inner link moves u by Δu, the outer moves y by Δy, and as long as Δu is not 0 the ratio for the whole chain splits into the two links' ratios. On the page that is the stretches of the bands multiplying.
    ΔyΔx=ΔyΔu⋅ΔuΔx(Δu≠0)\frac{\Delta y}{\Delta x}=\frac{\Delta y}{\Delta u}\cdot\frac{\Delta u}{\Delta x}\qquad(\Delta u\neq0)
  2. Let Δx shrink. Because g is continuous at x, Δu shrinks with it. The inner ratio tends to g′(x) and the outer one to f′ at the point the outer link is working, u = g(x). The limit of a product is the product of the limits.
    ΔuΔx→g′(x),ΔyΔu→f′(u)=f′(g(x))⇒dydx=f′(g(x)) g′(x)\frac{\Delta u}{\Delta x}\to g'(x),\qquad\frac{\Delta y}{\Delta u}\to f'(u)=f'\bigl(g(x)\bigr)\quad\Rightarrow\quad\frac{dy}{dx}=f'\bigl(g(x)\bigr)\,g'(x)
  3. The case the split hides. If Δu is 0 for some small Δx, the first line divides by zero. The careful proof gives the outer ratio the value f′(u) whenever Δu = 0. Then the product holds for every Δx, and its limit is the same.
Assumes
Each link has a derivative at the point it works at. Where one does not, as √u has none at 0, the rule says nothing, and the page prints the chain as undefined there.

Problems solved in full

  1. A power of a linear expression 3 steps

    Differentiate y = (3x + 1)⁴ and give the slope at x = 0.

    Open this problem in the tool

    1. Name the links and their rates. The inner link is the linear part, the outer one is the fourth power:

      u=3x+1,dudx=3;y=u4,dydu=4u3u=3x+1,\quad\frac{du}{dx}=3;\qquad y=u^{4},\quad\frac{dy}{du}=4u^{3}
    2. Multiply, outer rate first, and write the result as an exam would, with the constant in front:

      dydx=4(3x+1)3⋅3=12(3x+1)3\frac{dy}{dx}=4(3x+1)^{3}\cdot3=12(3x+1)^{3}
    3. At x = 0 the inner value is 1:

      x=0:12⋅13=12x=0:\quad 12\cdot1^{3}=12

    Answer

    dy/dx = 12(3x + 1)³, and 12 at x = 0. The 3 is the step everyone drops: the outer rate alone would give 4(3x + 1)³, a third of the true slope. The page shows the two rates as 3 and 4 and their product as 12.

    dydx=12(3x+1)3\frac{dy}{dx}=12(3x+1)^{3}
  2. A sine of a square 3 steps

    Differentiate y = sin(x²) and give the slope at x = 1.

    Open this problem in the tool

    Show solution
    1. The links and their rates:

      u=x2,dudx=2x;y=sin⁡u,dydu=cos⁡uu=x^{2},\quad\frac{du}{dx}=2x;\qquad y=\sin u,\quad\frac{dy}{du}=\cos u
    2. Multiply. The cosine is taken at u = x², where the outer link is working, not at x:

      dydx=cos⁡(x2)⋅2x=2xcos⁡(x2)\frac{dy}{dx}=\cos\left(x^{2}\right)\cdot2x=2x\cos\left(x^{2}\right)
    3. At x = 1:

      x=1:2cos⁡1≈1.0806x=1:\quad 2\cos1\approx1{.}0806

    Answer

    dy/dx = 2x cos(x²), and 2 cos 1 ≈ 1.0806 at x = 1. The page prints the outer rate there as 0.5403, which is cos 1, because u = x² is 1 at that point.

    dydx=2xcos⁡(x2)\frac{dy}{dx}=2x\cos\left(x^{2}\right)
  3. Where e^(−x²) is flat 3 steps

    Differentiate y = e^(−x²), find where its slope is zero, and give the slope at x = 1.

    Open this problem in the tool

    Show solution
    1. The links and their rates. e to a power is its own derivative:

      u=−x2,dudx=−2x;y=eu,dydu=euu=-x^{2},\quad\frac{du}{dx}=-2x;\qquad y=e^{u},\quad\frac{dy}{du}=e^{u}
    2. Multiply:

      dydx=e−x2⋅(−2x)=−2x e−x2\frac{dy}{dx}=e^{-x^{2}}\cdot(-2x)=-2x\,e^{-x^{2}}
    3. The exponential is never zero, so only the factor −2x can vanish:

      e−x2>0 ⇒ dydx=0  ⟺  x=0;x=1: −2e≈−0.7358e^{-x^{2}}>0\ \Rightarrow\ \frac{dy}{dx}=0\iff x=0;\qquad x=1:\ -\frac{2}{e}\approx-0{.}7358

    Answer

    dy/dx = −2x e^(−x²): flat only at x = 0, and −2/e ≈ −0.7358 at x = 1. Left of 0 the slope is positive and right of it negative, so x = 0 is the top of the curve.

    dydx=−2x e−x2\frac{dy}{dx}=-2x\,e^{-x^{2}}
  4. A logarithm of a sum 3 steps

    Differentiate y = ln(x² + 1) and give the slope at x = 1.

    Open this problem in the tool

    Show solution
    1. The links and their rates:

      u=x2+1,dudx=2x;y=ln⁡u,dydu=1uu=x^{2}+1,\quad\frac{du}{dx}=2x;\qquad y=\ln u,\quad\frac{dy}{du}=\frac{1}{u}
    2. Multiply:

      dydx=1x2+1⋅2x=2xx2+1\frac{dy}{dx}=\frac{1}{x^{2}+1}\cdot2x=\frac{2x}{x^{2}+1}
    3. At x = 1 the inner value is 2:

      x=1:22=1x=1:\quad\frac{2}{2}=1

    Answer

    dy/dx = 2x/(x² + 1), and exactly 1 at x = 1. The page prints the outer rate as 0.5, which is 1/u at u = 2.

    dydx=2xx2+1\frac{dy}{dx}=\frac{2x}{x^{2}+1}
  5. A negative power 3 steps

    Differentiate y = 1/(2x − 1)³ and give the slope at x = 1.

    Open this problem in the tool

    Show solution
    1. Write it as a power first; then the links and their rates follow as before:

      y=(2x−1)−3:u=2x−1,dudx=2;y=u−3,dydu=−3u−4y=(2x-1)^{-3}:\quad u=2x-1,\quad\frac{du}{dx}=2;\qquad y=u^{-3},\quad\frac{dy}{du}=-3u^{-4}
    2. Multiply and turn the negative power back into a fraction:

      dydx=−3(2x−1)−4⋅2=−6(2x−1)4\frac{dy}{dx}=-3(2x-1)^{-4}\cdot2=-\frac{6}{(2x-1)^{4}}
    3. At x = 1 the inner value is 1:

      x=1:−61=−6x=1:\quad-\frac{6}{1}=-6

    Answer

    dy/dx = −6/(2x − 1)⁴, and −6 at x = 1. Written as a power, a quotient with a constant on top needs no quotient rule at all.

    dydx=−6(2x−1)4\frac{dy}{dx}=-\frac{6}{(2x-1)^{4}}
  6. The cube of a sine 3 steps

    Differentiate y = sin³x and give the slope at x = π/4.

    Open this problem in the tool

    Show solution
    1. sin³x is a cube of sin x, so the power is the outer link and the sine the inner one:

      sin⁡3x=(sin⁡x)3:u=sin⁡x,dudx=cos⁡x;y=u3,dydu=3u2\sin^{3}x=(\sin x)^{3}:\quad u=\sin x,\quad\frac{du}{dx}=\cos x;\qquad y=u^{3},\quad\frac{dy}{du}=3u^{2}
    2. Multiply:

      dydx=3sin⁡2xcos⁡x\frac{dy}{dx}=3\sin^{2}x\cos x
    3. At π/4 the sine and the cosine are both √2/2:

      x=π4:3⋅12⋅22=324≈1.0607x=\tfrac{\pi}{4}:\quad3\cdot\tfrac12\cdot\tfrac{\sqrt2}{2}=\tfrac{3\sqrt2}{4}\approx1{.}0607

    Answer

    dy/dx = 3 sin²x cos x, and 3√2/4 ≈ 1.0607 at x = π/4. Read sin³x as sin(x³) and you have built a different chain, with the links the other way round.

    dydx=3sin⁡2xcos⁡x\frac{dy}{dx}=3\sin^{2}x\cos x
  7. Three links 3 steps

    Differentiate y = e^(sin(x²)) and give the slope at x = 1.

    Open this problem in the tool

    Show solution
    1. Three links, three rates, each taken where its link is working:

      u=x2, dudx=2x;w=sin⁡u, dwdu=cos⁡u;y=ew, dydw=ewu=x^{2},\ \frac{du}{dx}=2x;\quad w=\sin u,\ \frac{dw}{du}=\cos u;\quad y=e^{w},\ \frac{dy}{dw}=e^{w}
    2. Multiply all three, outer first:

      dydx=esin⁡(x2)⋅cos⁡(x2)⋅2x\frac{dy}{dx}=e^{\sin(x^{2})}\cdot\cos\left(x^{2}\right)\cdot2x
    3. At x = 1:

      x=1:esin⁡1⋅cos⁡1⋅2≈2.3198⋅0.5403⋅2≈2.5068x=1:\quad e^{\sin1}\cdot\cos1\cdot2\approx2{.}3198\cdot0{.}5403\cdot2\approx2{.}5068

    Answer

    dy/dx = 2x cos(x²) e^(sin(x²)), about 2.5068 at x = 1. One more link is one more factor, and the method does not change.

    dydx=2xcos⁡(x2)esin⁡(x2)\frac{dy}{dx}=2x\cos\left(x^{2}\right)e^{\sin(x^{2})}
  8. A product with a chain inside 3 steps

    Differentiate y = x² sin(3x) and give the slope at x = π/6.

    Show solution
    1. It is a product first. The second factor is a chain, so its derivative brings out the inner rate 3:

      u=x2,u′=2xv=sin⁡(3x),v′=3cos⁡(3x)\begin{aligned}u&=x^{2},&u'&=2x\\v&=\sin(3x),&v'&=3\cos(3x)\end{aligned}
    2. Assemble with the product rule:

      y′=2xsin⁡(3x)+3x2cos⁡(3x)y'=2x\sin(3x)+3x^{2}\cos(3x)
    3. At π/6 the angle 3x is π/2, where the sine is 1 and the cosine 0:

      x=π6:sin⁡π2=1,  cos⁡π2=0y′=2⋅π6=π3\begin{aligned}&x=\tfrac{\pi}{6}:\quad\sin\tfrac{\pi}{2}=1,\ \ \cos\tfrac{\pi}{2}=0\\&y'=2\cdot\tfrac{\pi}{6}=\tfrac{\pi}{3}\end{aligned}

    Answer

    y′ = 2x sin(3x) + 3x² cos(3x), and the slope at π/6 is π/3 ≈ 1.0472. The outermost operation is the multiplication, so the product rule leads and the chain rule works inside it. Leave out the 3 and you get the same π/3 here, because the cosine term is zero at π/6: a one-point check cannot see that slip, so check a second point.

    y′=2xsin⁡(3x)+3x2cos⁡(3x)y′ ⁣(π6)=π3≈1.0472\begin{aligned}&y'=2x\sin(3x)+3x^{2}\cos(3x)\\&y'\!\left(\tfrac{\pi}{6}\right)=\tfrac{\pi}{3}\approx1{.}0472\end{aligned}
  9. A quotient with a chain inside 3 steps

    Differentiate y = x/√(x² + 1) and give the slope at x = 1.

    Show solution
    1. A quotient whose bottom is a chain. Its derivative comes first:

      u=x,u′=1v=x2+1v′=2x2x2+1=xx2+1\begin{aligned}u&=x,\quad u'=1\\v&=\sqrt{x^{2}+1}\\v'&=\dfrac{2x}{2\sqrt{x^{2}+1}}=\dfrac{x}{\sqrt{x^{2}+1}}\end{aligned}
    2. The quotient rule, then one fraction, by multiplying top and bottom by √(x² + 1):

      y′=x2+1−x⋅xx2+1x2+1=(x2+1)−x2(x2+1)3/2=1(x2+1)3/2\begin{aligned}y'&=\dfrac{\sqrt{x^{2}+1}-x\cdot\dfrac{x}{\sqrt{x^{2}+1}}}{x^{2}+1}\\&=\dfrac{\left(x^{2}+1\right)-x^{2}}{\left(x^{2}+1\right)^{3/2}}=\dfrac{1}{\left(x^{2}+1\right)^{3/2}}\end{aligned}
    3. At x = 1:

      x=1:y′=123/2=122≈0.3536x=1:\quad y'=\dfrac{1}{2^{3/2}}=\dfrac{1}{2\sqrt{2}}\approx0{.}3536

    Answer

    y′ = 1/(x² + 1)^(3/2), and the slope at x = 1 is 1/(2√2) ≈ 0.3536. The derivative is positive for every x, so the curve rises everywhere, yet it never reaches 1: the line y = 1 is an asymptote that the graph approaches from below.

    y′=1(x2+1)3/2,y′(1)≈0.3536y'=\dfrac{1}{\left(x^{2}+1\right)^{3/2}},\qquad y'(1)\approx0{.}3536
  10. How many presses of cos? 4 steps

    A calculator in radians shows 1, and you keep pressing cos. Near p = 0.739085…, where cos p = p, each press multiplies the error by cos′(p) = −sin p = −0.6736. Estimate how many presses bring the display within 10⁻⁶ of p, then check the estimate. Press From x = 1: three presses take 1 to 0.6543, and the slope of the three-link chain there is −0.3273.

    Open this problem in the tool

    Show solution
    1. The error before the first press:

      e0=1−p=1−0.739085=0.2609e_0=1-p=1-0{.}739085=0{.}2609
    2. n presses are an n-link chain, and near p every link has the same rate, so the chain rule multiplies n equal factors:

      ddxcos⁡(cos⁡(⋯cos⁡x))⏟n∣x=p=(−sin⁡p)n=(−0.6736)n,∣en∣≈0.2609×0.6736n\frac{d}{dx}\underbrace{\cos(\cos(\cdots\cos x))}_{n}\Big|_{x=p}=(-\sin p)^{n}=(-0{.}6736)^{n},\qquad |e_n|\approx0{.}2609\times0{.}6736^{n}
    3. Ask for that to fall below 10⁻⁶ and take logarithms:

      0.2609×0.6736n<10−6  ⟺  n>ln⁡(0.2609/10−6)ln⁡(1/0.6736)=12.470.3951=31.570{.}2609\times0{.}6736^{n}<10^{-6}\iff n>\frac{\ln(0{.}2609/10^{-6})}{\ln(1/0{.}6736)}=\frac{12{.}47}{0{.}3951}=31{.}57
    4. The page's three presses test the estimate early, where it is still rough: it predicts −0.0797 and the display is out by −0.0848, because the first presses happen far from p.

      e3≈0.2609×(−0.3057)=−0.0797,e3=0.6543−0.7391=−0.0848e_3\approx0{.}2609\times(-0{.}3057)=-0{.}0797,\qquad e_3=0{.}6543-0{.}7391=-0{.}0848

    Answer

    32 presses. The estimate says 31.57, so 32, and running the iteration agrees: after 31 presses the error is 1.286×10⁻⁶ and after 32 it is 8.664×10⁻⁷. Each error divided by the one before is −0.7619 at the first press and −0.5960 at the second, and settles on −0.6736 as the presses close in. The page stops at three links.

    n=32:∣e31∣=1.286×10−6,∣e32∣=8.664×10−7n=32:\quad |e_{31}|=1{.}286\times10^{-6},\qquad |e_{32}|=8{.}664\times10^{-7}

Supplementary problems, answers only

  1. Differentiate (5 − 2x)⁶.

    Show answer

    −12(5 − 2x)⁵

    y′=−12(5−2x)5y'=-12(5-2x)^{5}
  2. Differentiate cos(3x²).

    Show answer

    −6x sin(3x²)

    y′=−6xsin⁡(3x2)y'=-6x\sin\left(3x^{2}\right)
  3. Differentiate √(4x + 1) and give the slope at x = 2.

    Show answer

    2/√(4x + 1), which is 2/3 at x = 2

    y′=24x+1,y′(2)=23y'=\dfrac{2}{\sqrt{4x+1}},\qquad y'(2)=\tfrac23
  4. Differentiate e^(sin x) and give the slope at x = 0.

    Show answer

    cos x · e^(sin x), which is 1 at x = 0

    y′=cos⁡x esin⁡x,y′(0)=1y'=\cos x\,e^{\sin x},\qquad y'(0)=1
  5. Differentiate ln(cos x) for −π/2 < x < π/2.

    Show answer

    −tan x

    y′=−tan⁡xy'=-\tan x
  6. Differentiate x²(x − 1)³ and factorise the answer.

    Show answer

    x(x − 1)²(5x − 2)

    y′=x(x−1)2(5x−2)y'=x(x-1)^{2}(5x-2)

A forgotten inner factor can pass a check at one point

Press Forgot the inside. The chain is sin(x²) at x = 2, and the typed answer cos(x²) has left out the inner rate, 2x. There it is wrong by a factor of 4. Now press A one-point check: the same answer at x = 0.5, where 2x is exactly 1, and it agrees with the true slope. A derivative tested at one point proves nothing if the inner rate happens to be 1 there. The page tests 24 points and refuses this one at every one of them.

Three presses of cos turn an error round three times

Press cos three times. The chain is cos(cos(cos x)) at 0.739085…, the one number cos leaves where it is. Every link works at the same point and has the same rate, about −0.67, so each band comes out turned round and a third shorter. That is what pressing cos over and over on a calculator does: near 0.7391 each press keeps about two-thirds of the error and flips its sign, so the display lands above, then below, closing in. The last solved problem counts the presses.

e to the ln x tells you the derivative of ln x

Press e to the ln x. The two links hand back what they were given, e^(ln x) = x, so the whole chain has slope 1. The chain rule says that 1 is the product of the two rates: the outer one, e^(ln x), which is x, times the rate of ln. So the rate of ln at x has to be 1/x, and the argument never needed to know it. Move x and the two rates stay reciprocals.

Learning path

Differentiation: how rates combine

References (2)