If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Chain rule overview

A quick overview sheet of the chain rule.

Introduction

If f, left parenthesis, x, right parenthesis and g, left parenthesis, x, right parenthesis are two functions, for instance f, left parenthesis, x, right parenthesis, equals, x, squared and g, left parenthesis, x, right parenthesis, equals, sine, left parenthesis, x, right parenthesis, we know how to take the derivative of their sum:
Rule:start fraction, d, divided by, d, x, end fraction, left parenthesis, f, left parenthesis, x, right parenthesis, plus, g, left parenthesis, x, right parenthesis, right parenthesis, equals, f, prime, left parenthesis, x, right parenthesis, plus, g, prime, left parenthesis, x, right parenthesis
Example:start fraction, d, divided by, d, x, end fraction, left parenthesis, x, squared, plus, sine, left parenthesis, x, right parenthesis, right parenthesis, equals, 2, x, plus, cosine, left parenthesis, x, right parenthesis
We also know how to take the derivative of their product:
Rule:start fraction, d, divided by, d, x, end fraction, left parenthesis, f, left parenthesis, x, right parenthesis, g, left parenthesis, x, right parenthesis, right parenthesis, equals, f, left parenthesis, x, right parenthesis, g, prime, left parenthesis, x, right parenthesis, plus, g, left parenthesis, x, right parenthesis, f, prime, left parenthesis, x, right parenthesis
Example:start fraction, d, divided by, d, x, end fraction, left parenthesis, x, squared, dot, sine, left parenthesis, x, right parenthesis, right parenthesis, equals, x, squared, cosine, left parenthesis, x, right parenthesis, plus, sine, left parenthesis, x, right parenthesis, dot, 2, x
The chain rule now tells us how to take the derivative of their composition, meaning f, left parenthesis, g, left parenthesis, x, right parenthesis, right parenthesis:
Rule:start color #0c7f99, start fraction, d, divided by, d, x, end fraction, left parenthesis, f, left parenthesis, g, left parenthesis, x, right parenthesis, right parenthesis, equals, f, prime, left parenthesis, g, left parenthesis, x, right parenthesis, right parenthesis, g, prime, left parenthesis, x, right parenthesis, end color #0c7f99
Example:start color #0c7f99, start fraction, d, divided by, d, x, end fraction, left parenthesis, sine, left parenthesis, x, right parenthesis, right parenthesis, squared, equals, 2, left parenthesis, sine, left parenthesis, x, right parenthesis, right parenthesis, cosine, left parenthesis, x, right parenthesis, end color #0c7f99

Intuition using fake algebra

Warning: The following section may induce headache or queasiness for readers who are sensitive to violent abuse of notation.
We tend to write functions and derivatives in terms of the variable x.
start fraction, d, divided by, d, x, end fraction, left parenthesis, x, squared, right parenthesis, equals, 2, x
But of course, we could use any other letter.
start fraction, d, divided by, d, start color #11accd, a, end color #11accd, end fraction, left parenthesis, start color #11accd, a, end color #11accd, squared, right parenthesis, equals, 2, start color #11accd, a, end color #11accd
What if we did something crazy, and replaced x with a function instead of another letter.
start fraction, d, divided by, d, left parenthesis, start color #11accd, sine, left parenthesis, x, right parenthesis, end color #11accd, right parenthesis, end fraction, left parenthesis, start color #11accd, sine, left parenthesis, x, right parenthesis, end color #11accd, right parenthesis, squared, equals, 2, start color #11accd, sine, left parenthesis, x, right parenthesis, end color #11accd
It's unclear exactly what this start fraction, d, divided by, d, left parenthesis, sine, left parenthesis, x, right parenthesis, right parenthesis, end fraction symbol would mean, but let's just go with it for a second. We can imagine multiplying it by start fraction, d, left parenthesis, sine, left parenthesis, x, right parenthesis, right parenthesis, divided by, d, x, end fraction to "cancel out" the d, left parenthesis, sine, left parenthesis, x, right parenthesis, right parenthesis term:
start fraction, d, left parenthesis, sine, left parenthesis, x, right parenthesis, right parenthesis, squared, divided by, start cancel, d, left parenthesis, sine, left parenthesis, x, right parenthesis, right parenthesis, end cancel, end fraction, dot, start fraction, start cancel, d, left parenthesis, sine, left parenthesis, x, right parenthesis, right parenthesis, end cancel, divided by, d, x, end fraction, equals, start fraction, d, divided by, d, x, end fraction, left parenthesis, sine, left parenthesis, x, right parenthesis, right parenthesis, squared
This is not really a mathematically legitimate thing to do, since these "d, x" and "d, left parenthesis, sine, left parenthesis, x, right parenthesis, right parenthesis" terms are not numbers or functions that we can cancel out. There are ways to make this more legitimate that involve some more advanced math, but for now you can think of it as a useful memory trick. The usefulness is that when we expand start fraction, d, divided by, d, x, end fraction, left parenthesis, sine, left parenthesis, x, right parenthesis, right parenthesis, squared like this, we know what each individual term is, even if we don't know how to take the derivative of left parenthesis, sine, left parenthesis, x, right parenthesis, right parenthesis, squared:
This trick looks particularly clean when we write it in the abstract, rather than with the specific case of x, squared and sine, left parenthesis, x, right parenthesis:
start box, start fraction, d, divided by, d, x, end fraction, open bracket, f, left parenthesis, g, left parenthesis, x, right parenthesis, right parenthesis, close bracket, equals, start fraction, d, f, divided by, d, g, end fraction, dot, start fraction, d, g, divided by, d, x, end fraction, end box

Example 1:

f(x)=sin(x2)Function to differentiateu(x)=x2Define u(x) as inside functionf(x)=sin(u)Express f(x) in terms of u(x)dfdx=dfdududxExpress chain rule applicable heredfdx=ddusin(u)ddx(x2)Substitute in f(u) and u(x)dfdx=cos(u)2xEvaluate derivativesdfdx=cos(x2)(2x)Substitute u in terms of x.\begin{aligned} f(x) &= \sin(x^2) \quad \quad \small{\gray{\text{Function to differentiate}}} \\ & \\ u(x) &= x^2 \quad \quad \small{\gray{\text{Define $u(x)$ as inside function}}} \\ & \\ f(x) &= \sin(u) \quad \quad \small{\gray{\text{Express $f(x)$ in terms of $u(x)$}}} \\ & \\ \frac{df}{dx} &= \frac{df}{du} \cdot \frac {du}{dx} \quad \quad \small{\gray{\text{Express chain rule applicable here}}} \\ & \\ \frac{df}{dx} &= \frac{d}{du}\sin(u) \cdot\frac {d}{dx}(x^2) \quad \quad \small{\gray{\text{Substitute in $f(u)$ and $u(x)$}}} \\ & \\ \frac{df}{dx} &= \cos(u) \cdot 2x \quad \quad \small{\gray{\text{Evaluate derivatives}}} \\ & \\ \frac{df}{dx} &= \cos(x^2)(2x) \quad \quad \small{\gray{\text{Substitute $u$ in terms of $x$.}}} \\ & \\ \end{aligned}

Example 2:

One pretty cool thing we can now do is find the derivative of the absolute value function vertical bar, x, vertical bar, which can be defined as square root of, x, squared, end square root. For example, vertical bar, minus, 5, vertical bar, equals, square root of, left parenthesis, minus, 5, right parenthesis, squared, end square root, equals, square root of, 25, end square root, equals, 5
f(x)=xFunction to differentiatef(x)=x2Equivalent functionu(x)=x2Define u(x) as inside functionf(x)=[u(x)]12Express f(x) in terms of u(x)dfdx=dfdududxExpress chain rule applicable heredfdx=dduu12ddx(x2)Substitute in f(u) and u(x)dfdx=12u122xCompute derivatives with power ruledfdx=12(x2)122xSubstitute u(x) back in terms of xdfdx=xx2Simplifydfdx=xxExpress x2 as absolute value.\begin{aligned} f(x) &= \left|x\right| \quad \quad \small{\gray{\text{Function to differentiate}}} \\ & \\ f(x) &= \sqrt{x^2} \quad \quad \small{\gray{\text{Equivalent function}}} \\ & \\ u(x) &= x^2 \quad \quad \small{\gray{\text{Define $u(x)$ as inside function}}} \\ & \\ f(x) &= [u(x)]^\frac{1}{2} \quad \quad \small{\gray{\text{Express $f(x)$ in terms of $u(x)$}}} \\ & \\ \frac{df}{dx} &= \frac{df}{du} \cdot \frac {du}{dx} \quad \quad \small{\gray{\text{Express chain rule applicable here}}} \\ & \\ \frac{df}{dx} &= \frac{d}{du}u^\frac{1}{2} \cdot\frac {d}{dx}(x^2) \quad \quad \small{\gray{\text{Substitute in $f(u)$ and $u(x)$}}} \\ & \\ \frac{df}{dx} &= \frac{1}{2}u^{-\frac{1}{2}} \cdot 2x \quad \quad \small{\gray{\text{Compute derivatives with power rule}}} \\ & \\ \frac{df}{dx} &= \frac{1}{2}\left(x^2\right)^{-\frac{1}{2}} \cdot 2x \quad \quad \small{\gray{\text{Substitute $u(x)$ back in terms of $x$}}} \\ & \\ \frac{df}{dx} &= \frac{x}{\sqrt{x^2}} \quad \quad \small{\gray{\text{Simplify}}} \\ & \\ \frac{df}{dx} &= \frac{x}{\left|x\right|} \quad \quad \small{\gray{\text{Express $\sqrt{x^2}$ as absolute value.}}} \\ & \\ \end{aligned}

Arbitrarily long composition

The chain rule can apply to composing multiple functions, not just two. For example, suppose A, left parenthesis, x, right parenthesis, B, left parenthesis, x, right parenthesis, C, left parenthesis, x, right parenthesis and D, left parenthesis, x, right parenthesis are four different functions, and define f to be their composition:
f, left parenthesis, x, right parenthesis, equals, A, left parenthesis, B, left parenthesis, C, left parenthesis, D, left parenthesis, x, right parenthesis, right parenthesis, right parenthesis, right parenthesis
Using the start fraction, d, f, divided by, d, x, end fraction notation for the derivative, we can apply the chain rule as:
start fraction, d, f, divided by, d, x, end fraction, equals, start fraction, d, divided by, d, x, end fraction, A, left parenthesis, B, left parenthesis, C, left parenthesis, D, left parenthesis, x, right parenthesis, right parenthesis, right parenthesis, equals, start fraction, d, A, divided by, d, B, end fraction, dot, start fraction, d, B, divided by, d, C, end fraction, dot, start fraction, d, C, divided by, d, D, end fraction, dot, start fraction, d, D, divided by, d, x, end fraction
Using f, prime notation, we get more of a snowman aesthetic:
f, prime, left parenthesis, x, right parenthesis, equals, A, prime, left parenthesis, B, left parenthesis, C, left parenthesis, D, left parenthesis, x, right parenthesis, right parenthesis, right parenthesis, right parenthesis, dot, B, prime, left parenthesis, C, left parenthesis, D, left parenthesis, x, right parenthesis, right parenthesis, right parenthesis, dot, C, prime, left parenthesis, D, left parenthesis, x, right parenthesis, right parenthesis, dot, D, prime, left parenthesis, x, right parenthesis

Example 4:

Suppose f, left parenthesis, x, right parenthesis, equals, sine, left parenthesis, e, start superscript, x, squared, plus, x, end superscript, right parenthesis.
We think of f as being the composition of
A(x)=sin(x)B(x)=exC(x)=x2+x\begin{aligned} A(x) &= \blueE{\sin(x)}\\ B(x) &= \greenE{e^x} \\ C(x) &= \redE{x^2 + x} \end{aligned}
Where the derivative of each function is
A(x)=cos(x)B(x)=exC(x)=2x+1\begin{aligned} A'(x) &= \blueE{\cos(x)}\\ B'(x) &= \greenE{e^x} \\ C'(x) &= \redE{2x + 1} \end{aligned}
According to the chain rule, the derivative of the composition is
f(x)=A(B(C(x)))B(C(x))C(x)=cos(ex2+x)ex2+x(2x+1)\begin{aligned} f'(x) &= A'(B(C(x))) \cdot B'(C(x)) \cdot C'(x) \\ & \\ &= \boxed{\large \blueD{\cos}(e^{x^2 + x}) \cdot \greenD{e}^{x^2 + x} \cdot \redD{(2x + 1)}} \end{aligned}

Want to join the conversation?