Skip to content

Unit 3: Differentiation: Composite, Implicit, and Inverse Functions

The Chain Rule

Differentiate any composition, given as a formula, a table, or a graph, by multiplying the outside's derivative at the inside by the inside's derivative.

Topic 3.1 · 10 min read

You can differentiate sin⁡x\sin x and you can differentiate x3x^3, but sin⁡(x3)\sin(x^3) is neither of those: it is the sine of a quantity that is itself changing. Functions built by feeding one function into another are called compositions, such as e−0.2te^{-0.2t}, 1+x2\sqrt{1+x^2} and ln⁡(cos⁡x)\ln(\cos x). The chain rule differentiates every one of them, and it rests on a single fact: when one quantity drives another, their rates of change multiply.

Outside and inside

A composition h(x)=f(g(x))h(x) = f(g(x)) is computed in two stages. The inner function gg turns xx into a number u=g(x)u = g(x), and then the outer function ff turns uu into f(u)f(u). To find the layers of a formula, ask what you would do last if you evaluated it at x=3x = 3 by hand. For sin⁡(x3)\sin(x^3) you would cube 3 first and take the sine last, so the outside is sin⁡u\sin u and the inside is u=x3u = x^3.

FunctionInside uuOutside
sin⁡(x3)\sin(x^3)x3x^3sin⁡u\sin u
sin⁡3x=(sin⁡x)3\sin^3 x = (\sin x)^3sin⁡x\sin xu3u^3
e−0.2te^{-0.2t}−0.2t-0.2teue^u
1+x2\sqrt{1+x^2}1+x21+x^2u\sqrt{u}
ln⁡(cos⁡x)\ln(\cos x)cos⁡x\cos xln⁡u\ln u

The first two rows use the same two pieces in opposite orders. sin⁡(x3)\sin(x^3) cubes the input before the sine acts; sin⁡3x\sin^3 x takes the sine first and cubes the output.

A product is not a composition. In x3sin⁡xx^3\sin x, the two pieces are computed separately from xx and then multiplied; neither one is fed into the other, so that function needs the product rule (topic 2.8).

Why the rates multiply

Suppose uu changes 3 times as fast as xx, and yy changes 4 times as fast as uu. A small nudge to xx is magnified by 3 on its way to uu, and that change in uu is magnified by 4 on its way to yy, so yy changes 3⋅4=123 \cdot 4 = 12 times as fast as xx. Gears work the same way: if gear A turns gear B 3 times per turn and gear B turns gear C 4 times per turn, then C turns 12 times for each turn of A. With y=f(u)y = f(u) and u=g(x)u = g(x), Leibniz notation writes this as

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

Here is where it comes from. Give xx a small change Δx\Delta x. That changes uu by some Δu\Delta u, which in turn changes yy by some Δy\Delta y. As long as Δu≠0\Delta u \neq 0, ordinary algebra gives

ΔyΔx=ΔyΔu⋅ΔuΔx.\frac{\Delta y}{\Delta x} = \frac{\Delta y}{\Delta u}\cdot\frac{\Delta u}{\Delta x}.

Now let Δx→0\Delta x \to 0. The second fraction approaches g′(x)g'(x). Because gg is differentiable at xx, it is continuous there (topic 2.4), so Δu→0\Delta u \to 0 as well, and the first fraction approaches f′(u)f'(u), the derivative of ff at u=g(x)u = g(x). If Δu\Delta u happens to equal 0 for arbitrarily small Δx\Delta x, the first fraction is undefined; a more careful proof patches that case and gets the same rule. The dudu's in Leibniz notation look like they cancel, which is a good memory aid, but the limit argument is the actual reason.

The outside derivative is evaluated at g(x)g(x), not at xx, because ff never receives xx. Its input is u=g(x)u = g(x), so its rate of change has to be measured at the value of uu it is actually given.

You can test the rule on a function you can also expand. For h(x)=(3x+1)2h(x) = (3x+1)^2, the outside is u2u^2 and the inside is 3x+13x + 1, so

h′(x)=2(3x+1)⋅3=18x+6.h'(x) = 2(3x+1)\cdot 3 = 18x + 6.

Expanding first gives h(x)=9x2+6x+1h(x) = 9x^2 + 6x + 1 and h′(x)=18x+6h'(x) = 18x + 6, the same answer. Leaving off the inside derivative gives 2(3x+1)=6x+22(3x+1) = 6x + 2, which is too small by exactly the factor of 3 at which the inside changes.

Every rule you know, with an inside

Each derivative rule from Unit 2 becomes a chain rule pattern when its input is a function g(x)g(x) instead of xx: differentiate the outside as usual, keep g(x)g(x) as its input, and multiply by g′(x)g'(x).

FunctionDerivative
[g(x)]n[g(x)]^nn[g(x)]n−1 g′(x)n[g(x)]^{n-1}\,g'(x)
sin⁡(g(x))\sin(g(x))cos⁡(g(x)) g′(x)\cos(g(x))\,g'(x)
cos⁡(g(x))\cos(g(x))−sin⁡(g(x)) g′(x)-\sin(g(x))\,g'(x)
tan⁡(g(x))\tan(g(x))sec⁡2(g(x)) g′(x)\sec^2(g(x))\,g'(x)
eg(x)e^{g(x)}eg(x) g′(x)e^{g(x)}\,g'(x)
ln⁡(g(x))\ln(g(x)), where g(x)>0g(x) > 0g′(x)g(x)\dfrac{g'(x)}{g(x)}

The last row is the outside derivative 1u\frac{1}{u} evaluated at u=g(x)u = g(x), times g′(x)g'(x); it needs g(x)>0g(x) > 0 because ln⁡u\ln u is defined only for u>0u > 0. For example, ddxln⁡(x2+4)=2xx2+4\frac{d}{dx}\ln(x^2+4) = \frac{2x}{x^2+4}.

Four patterns are worth recognizing on sight:

  • A linear inside contributes its slope. ddxsin⁡(5x)=5cos⁡(5x)\frac{d}{dx}\sin(5x) = 5\cos(5x) and ddxe−x/2=−12e−x/2\frac{d}{dx}e^{-x/2} = -\frac{1}{2}e^{-x/2}. The same holds for a function you know only by name: ddxf(2x)=2f′(2x)\frac{d}{dx}f(2x) = 2f'(2x).
  • Roots and reciprocals are powers. Rewrite 1+x2\sqrt{1+x^2} as (1+x2)1/2(1+x^2)^{1/2}. Then its derivative is 12(1+x2)−1/2⋅2x=x1+x2\frac{1}{2}(1+x^2)^{-1/2}\cdot 2x = \frac{x}{\sqrt{1+x^2}}.
  • Exponentials with other bases. Since b=eln⁡bb = e^{\ln b}, you can write bx=exln⁡bb^x = e^{x\ln b}, an exponential whose inside xln⁡bx\ln b has slope ln⁡b\ln b. So ddxbx=bxln⁡b\frac{d}{dx}b^x = b^x\ln b, and for instance ddx2x=2xln⁡2≈0.693⋅2x\frac{d}{dx}2^x = 2^x\ln 2 \approx 0.693 \cdot 2^x.
  • A power of a trig function is a power first. sin⁡2x\sin^2 x has outside u2u^2, so its derivative is 2sin⁡xcos⁡x2\sin x\cos x. Compare sin⁡(x2)\sin(x^2), whose derivative is cos⁡(x2)⋅2x\cos(x^2)\cdot 2x.

Three or more layers, and other rules mixed in

With three layers, the chain rule applies at each link, so the derivative is a product of three factors. Work from the outside in: differentiate the outermost layer while leaving everything inside it untouched, multiply by the derivative of what was inside, and repeat until you reach xx. For y=ln⁡(cos⁡4x)y = \ln(\cos 4x), on an interval where cos⁡4x>0\cos 4x > 0, the layers are ln⁡u\ln u, then u=cos⁡vu = \cos v, then v=4xv = 4x:

dydx=1cos⁡4x⋅(−sin⁡4x)⋅4=−4tan⁡4x.\frac{dy}{dx} = \frac{1}{\cos 4x}\cdot(-\sin 4x)\cdot 4 = -4\tan 4x.

When products, quotients and compositions are mixed, the operation you would do last decides which rule you use first. In x2e−3xx^2e^{-3x} the last step is multiplying x2x^2 by e−3xe^{-3x}, so the product rule comes first, and the chain rule shows up inside it when you differentiate e−3xe^{-3x}:

ddx(x2e−3x)=2x e−3x+x2(−3e−3x)=e−3x(2x−3x2).\frac{d}{dx}\left(x^2e^{-3x}\right) = 2x\,e^{-3x} + x^2\left(-3e^{-3x}\right) = e^{-3x}\left(2x - 3x^2\right).

Compositions given by tables and graphs

The exam can give ff and gg only through a table of values or a graph. The rule does not change; you look up each number instead of computing it. For h(x)=f(g(x))h(x) = f(g(x)) at x=ax = a:

  1. Find the inside value g(a)g(a).
  2. Look up the outside derivative at that value, f′(g(a))f'(g(a)).
  3. Look up g′(a)g'(a) and multiply.

The two lookups come from different rows of the table, row aa for g′g' and row g(a)g(a) for f′f', and reading f′f' from row aa instead gives a wrong number.

On a graph, the derivative at a point is the slope there, so for a graph made of line segments, f′f' at an input is the slope of the segment containing it. If g(a)g(a) lands exactly on a corner of the graph of ff, then ff is not differentiable at g(a)g(a) and the chain rule's condition fails. When in addition g′(a)≠0g'(a) \neq 0, the composition really does have a corner at aa: its slopes on the two sides of aa are the two segment slopes, each multiplied by g′(a)g'(a), and they disagree. Example 3 works through one.

Worked examples

Worked exampleExample 1: a root in the denominator

Let f(x)=10x2+9f(x) = \dfrac{10}{\sqrt{x^2+9}}. Find f′(x)f'(x) and f′(4)f'(4).

Show solution

Rewrite the function as a power so that only the chain rule is needed: f(x)=10(x2+9)−1/2f(x) = 10\left(x^2+9\right)^{-1/2}. The outside is 10u−1/210u^{-1/2} and the inside is u=x2+9u = x^2 + 9, with dudx=2x\frac{du}{dx} = 2x.

f′(x)=10⋅(−12)(x2+9)−3/2⋅2x=−10x(x2+9)3/2.f'(x) = 10\cdot\left(-\tfrac{1}{2}\right)\left(x^2+9\right)^{-3/2}\cdot 2x = \frac{-10x}{\left(x^2+9\right)^{3/2}}.

At x=4x = 4, the inside is 16+9=2516 + 9 = 25 and 253/2=12525^{3/2} = 125, so

f′(4)=−40125=−825.f'(4) = \frac{-40}{125} = -\frac{8}{25}.

The sign makes sense: for x>0x > 0 the denominator grows as xx grows, so ff is decreasing there. The quotient rule would also work, but it would need the chain rule anyway to differentiate the denominator, so rewriting as a power is the shorter path.

Worked exampleExample 2: three layers and a tangent line

Let k(x)=esin⁡2xk(x) = e^{\sin^2 x}. Write an equation for the line tangent to the graph of kk at x=π4x = \dfrac{\pi}{4}.

Show solution

A tangent line needs a point and a slope, so find k(π4)k\left(\frac{\pi}{4}\right) and k′(π4)k'\left(\frac{\pi}{4}\right).

The layers, from outside in, are eue^u, then u=v2u = v^2, then v=sin⁡xv = \sin x. Differentiating one layer at a time:

k′(x)=esin⁡2x⋅2sin⁡x⋅cos⁡x.k'(x) = e^{\sin^2 x}\cdot 2\sin x\cdot\cos x.

At x=π4x = \frac{\pi}{4}, sin⁡x=cos⁡x=22\sin x = \cos x = \frac{\sqrt{2}}{2}, so sin⁡2x=12\sin^2 x = \frac{1}{2}. Then

k(π4)=e1/2,k′(π4)=e1/2⋅2⋅22⋅22=e1/2.k\left(\tfrac{\pi}{4}\right) = e^{1/2}, \qquad k'\left(\tfrac{\pi}{4}\right) = e^{1/2}\cdot 2\cdot\frac{\sqrt{2}}{2}\cdot\frac{\sqrt{2}}{2} = e^{1/2}.

The tangent line is

y=e1/2+e1/2(x−π4).y = e^{1/2} + e^{1/2}\left(x - \frac{\pi}{4}\right).

Point-slope form is a complete answer; there is no need to simplify it.

Worked exampleExample 3: a composition built on a graph

The graph of the function ff, which consists of three line segments, is shown below. Let j(x)=[f(x)]3j(x) = [f(x)]^3 and h(x)=f(x2+1)h(x) = f(x^2+1).

Graph of f on 0 to 6 made of three line segments joining the points (0, 1), (2, 5), (4, 3) and (6, 0). The segment slopes are 2 on 0 to 2, negative 1 on 2 to 4, and negative 3/2 on 4 to 6.

(a) Find j′(3)j'(3).

(b) Find h′(2)h'\left(\sqrt{2}\right).

(c) Is hh differentiable at x=1x = 1? Justify your answer.

Show solution

First read the slopes off the graph: f′=2f' = 2 on (0,2)(0, 2), f′=−1f' = -1 on (2,4)(2, 4), and f′=−32f' = -\frac{3}{2} on (4,6)(4, 6).

(a) The outside of jj is u3u^3 and the inside is f(x)f(x), so j′(x)=3[f(x)]2f′(x)j'(x) = 3[f(x)]^2 f'(x). The point x=3x = 3 is the midpoint of the segment from (2,5)(2, 5) to (4,3)(4, 3), so f(3)=4f(3) = 4 and f′(3)=−1f'(3) = -1:

j′(3)=3(4)2(−1)=−48.j'(3) = 3(4)^2(-1) = -48.

(b) Here the inside is x2+1x^2 + 1, so h′(x)=f′(x2+1)⋅2xh'(x) = f'(x^2+1)\cdot 2x. At x=2x = \sqrt{2} the inside is 33, which lies on the middle segment:

h′(2)=f′(3)⋅22=−22.h'\left(\sqrt{2}\right) = f'(3)\cdot 2\sqrt{2} = -2\sqrt{2}.

(c) At x=1x = 1 the inside is 22, a corner of the graph of ff, so the chain rule cannot be used there. Look at hh on each side instead. For xx slightly less than 1, x2+1x^2 + 1 is slightly less than 2, where f(u)=1+2uf(u) = 1 + 2u; so h(x)=1+2(x2+1)=2x2+3h(x) = 1 + 2(x^2 + 1) = 2x^2 + 3, whose slope at x=1x = 1 is 44. For xx slightly greater than 1, x2+1x^2 + 1 is slightly more than 2, where f(u)=7−uf(u) = 7 - u; so h(x)=6−x2h(x) = 6 - x^2, whose slope at x=1x = 1 is −2-2. The slope of hh from the left of x=1x = 1 is 44 and from the right is −2-2. They are not equal, so hh is not differentiable at x=1x = 1.

Worked exampleExample 4: an exam-style table question (no calculator)

The functions ff and gg are differentiable for all real numbers. The table below gives values of the functions and their derivatives at selected values of xx.

xf(x)f′(x)g(x)g′(x)13−2452143−13462242−313\begin{array}{c|cccc} x & f(x) & f'(x) & g(x) & g'(x) \\ \hline 1 & 3 & -2 & 4 & 5 \\ 2 & 1 & 4 & 3 & -1 \\ 3 & 4 & 6 & 2 & 2 \\ 4 & 2 & -3 & 1 & 3 \end{array}

(a) Let h(x)=f(g(x))h(x) = f(g(x)). Find h′(2)h'(2).

(b) Let k(x)=f(x)k(x) = \sqrt{f(x)}. Find k′(3)k'(3).

(c) Let w(x)=g(f(x))w(x) = g(f(x)). Write an equation for the line tangent to the graph of ww at x=1x = 1.

(d) Let p(x)=x f ⁣(x2)p(x) = x\,f\!\left(x^2\right). Find p′(2)p'(2).

Show solution

For each part, write the derivative rule in general first, then substitute table values. That line is the work the exam wants to see, and it makes a lookup error easy to spot.

(a) h′(x)=f′(g(x)) g′(x)h'(x) = f'(g(x))\,g'(x). The inside value is g(2)=3g(2) = 3, so the outside derivative comes from row 3:

h′(2)=f′(g(2)) g′(2)=f′(3)⋅(−1)=6(−1)=−6.h'(2) = f'(g(2))\,g'(2) = f'(3)\cdot(-1) = 6(-1) = -6.

(b) The outside is u\sqrt{u}, with derivative 12u\frac{1}{2\sqrt{u}}, and the inside is f(x)f(x):

k′(3)=f′(3)2f(3)=624=32.k'(3) = \frac{f'(3)}{2\sqrt{f(3)}} = \frac{6}{2\sqrt{4}} = \frac{3}{2}.

(c) The point: w(1)=g(f(1))=g(3)=2w(1) = g(f(1)) = g(3) = 2. The slope: the inside value is f(1)=3f(1) = 3, so

w′(1)=g′(f(1)) f′(1)=g′(3)⋅(−2)=2(−2)=−4.w'(1) = g'(f(1))\,f'(1) = g'(3)\cdot(-2) = 2(-2) = -4.

The tangent line is y=2−4(x−1)y = 2 - 4(x - 1).

(d) The last operation in pp is multiplying xx by f(x2)f(x^2), so start with the product rule; the second factor needs the chain rule with inside x2x^2:

p′(x)=1⋅f ⁣(x2)+x⋅f′ ⁣(x2)⋅2x.p'(x) = 1\cdot f\!\left(x^2\right) + x\cdot f'\!\left(x^2\right)\cdot 2x.

At x=2x = 2, the inside is x2=4x^2 = 4, so both lookups come from row 4:

p′(2)=f(4)+2⋅f′(4)⋅4=2+8(−3)=−22.p'(2) = f(4) + 2\cdot f'(4)\cdot 4 = 2 + 8(-3) = -22.

Where students lose points

On the exam

Questions that test the chain rule directly can give the composition as a formula, or give ff and gg only through a table or a graph so that you must look up g(a)g(a), f′(g(a))f'(g(a)) and g′(a)g'(a); they appear in multiple choice and as free-response parts. On no-calculator free-response parts, an unsimplified numeric answer such as 3(4)2(−1)3(4)^2(-1) is acceptable; the arithmetic is not what is being tested. On calculator-active questions, the calculator can find a derivative's value at a point, but when a question asks for f′(x)f'(x) as an expression, you have to produce it by hand.

Check yourself

  1. Question 1

    If y=cos⁡2(3x)y = \cos^2(3x), then dydx=\dfrac{dy}{dx} =

    1. A

      −6sin⁡(3x)cos⁡(3x)-6\sin(3x)\cos(3x)

    2. B

      −2sin⁡(3x)cos⁡(3x)-2\sin(3x)\cos(3x)

    3. C

      6cos⁡(3x)6\cos(3x)

    4. D

      −6sin⁡(3x)-6\sin(3x)

    Show answer

    A

    There are three layers: the square, the cosine, and 3x3x. Their derivatives are 2cos⁡(3x)2\cos(3x), −sin⁡(3x)-\sin(3x) and 33, and the product is −6sin⁡(3x)cos⁡(3x)-6\sin(3x)\cos(3x). Choice B stops one layer early and drops the factor of 3 from the innermost layer.

  2. Question 2

    Let h(x)=f(g(x))h(x) = f(g(x)), where ff and gg are differentiable. If g(2)=−1g(2) = -1, g′(2)=5g'(2) = 5 and h′(2)=−15h'(2) = -15, what is f′(−1)f'(-1)?

    Show answer

    f′(−1)=−3f'(-1) = -3

    By the chain rule, h′(2)=f′(g(2)) g′(2)=f′(−1)⋅5h'(2) = f'(g(2))\,g'(2) = f'(-1)\cdot 5. Setting 5f′(−1)=−155f'(-1) = -15 gives f′(−1)=−3f'(-1) = -3. The outside derivative is the one at g(2)=−1g(2) = -1, which is why the question can only be answered about f′(−1)f'(-1).

  3. Question 3

    The function ff is differentiable for all real numbers, and h(x)=f(x2)h(x) = f(x^2). What is h′(0)h'(0), and why don't you need to know anything about ff to answer?

    Show answer

    h′(0)=0h'(0) = 0, for every differentiable ff.

    The chain rule gives h′(x)=f′(x2)⋅2xh'(x) = f'(x^2)\cdot 2x. At x=0x = 0 the inside derivative 2x2x is 0, and f′(0)f'(0) is some finite number because ff is differentiable, so the product is 0 whatever f′(0)f'(0) is.

  4. Question 4

    What is the value of ddx ex\dfrac{d}{dx}\,e^{\sqrt{x}} at x=4x = 4?

    1. A

      e2e^2

    2. B

      e22\dfrac{e^2}{2}

    3. C

      e24\dfrac{e^2}{4}

    4. D

      e1/4e^{1/4}

    Show answer

    C

    The derivative is ex⋅12xe^{\sqrt{x}}\cdot\dfrac{1}{2\sqrt{x}}. At x=4x = 4 that is e2⋅14e^2\cdot\dfrac{1}{4}. Choice A forgets the inside derivative entirely, and choice D evaluates the exponential at the inside's derivative instead of multiplying by it.

  5. Question 5

    On a calm day the air temperature TT, in degrees Celsius, falls with altitude aa at the rate dTda=−6.5\dfrac{dT}{da} = -6.5 degrees Celsius per kilometer. A weather balloon rises at dadt=0.4\dfrac{da}{dt} = 0.4 kilometer per minute. At what rate is the temperature around the balloon changing with respect to time?

    Show answer

    dTdt=−2.6\dfrac{dT}{dt} = -2.6 degrees Celsius per minute (falling at 2.6 degrees Celsius per minute).

    Temperature depends on altitude, which depends on time, so dTdt=dTda⋅dadt=(−6.5)(0.4)=−2.6\dfrac{dT}{dt} = \dfrac{dT}{da}\cdot\dfrac{da}{dt} = (-6.5)(0.4) = -2.6. The units multiply the same way: degrees per kilometer times kilometers per minute gives degrees per minute.

Go deeper