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.


If f(x) and g(x) are two functions, for instance f(x)=x2 and g(x)=sin(x), we know how to take the derivative of their sum:
We also know how to take the derivative of their product:
The chain rule now tells us how to take the derivative of their composition, meaning f(g(x)):

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.
But of course, we could use any other letter.
What if we did something crazy, and replaced x with a function instead of another letter.
It's unclear exactly what this dd(sin(x)) symbol would mean, but let's just go with it for a second. We can imagine multiplying it by d(sin(x))dx to "cancel out" the d(sin(x)) term:
This is not really a mathematically legitimate thing to do, since these "dx" and "d(sin(x))" 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 ddx(sin(x))2 like this, we know what each individual term is, even if we don't know how to take the derivative of (sin(x))2:
ddx(sin(x))2=d(sin(x))2d(sin(x))Imagine replacing xwith sin(x) in d(x2)dxd(sin(x))dxOrdinary derivativeof sin(x)=2sin(x)cos(x)
This trick looks particularly clean when we write it in the abstract, rather than with the specific case of x2 and sin(x):

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.

Example 2:

One pretty cool thing we can now do is find the derivative of the absolute value function |x|, which can be defined as x2. For example, |5|=(5)2=25=5
f(x)=|x|Function 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=x|x|Express x2 as absolute value.

Arbitrarily long composition

The chain rule can apply to composing multiple functions, not just two. For example, suppose A(x), B(x), C(x) and D(x) are four different functions, and define f to be their composition:
Using the dfdx notation for the derivative, we can apply the chain rule as:
Using f notation, we get more of a snowman aesthetic:

Example 4:

Suppose f(x)=sin(ex2+x).
We think of f as being the composition of
Where the derivative of each function is
According to the chain rule, the derivative of the composition is

Want to join the conversation?