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.

# Chain rule overview

A quick overview sheet of the chain rule.

## Introduction

If $f\left(x\right)$ and $g\left(x\right)$ are two functions, for instance $f\left(x\right)={x}^{2}$ and $g\left(x\right)=\mathrm{sin}\left(x\right)$, we know how to take the derivative of their sum:
Rule:$\frac{d}{dx}\left(f\left(x\right)+g\left(x\right)\right)={f}^{\prime }\left(x\right)+{g}^{\prime }\left(x\right)$
Example:$\frac{d}{dx}\left({x}^{2}+\mathrm{sin}\left(x\right)\right)=2x+\mathrm{cos}\left(x\right)$
We also know how to take the derivative of their product:
Rule:$\frac{d}{dx}\left(f\left(x\right)g\left(x\right)\right)=f\left(x\right){g}^{\prime }\left(x\right)+g\left(x\right){f}^{\prime }\left(x\right)$
Example:$\frac{d}{dx}\left({x}^{2}\cdot \mathrm{sin}\left(x\right)\right)={x}^{2}\mathrm{cos}\left(x\right)+\mathrm{sin}\left(x\right)\cdot 2x$
The chain rule now tells us how to take the derivative of their composition, meaning $f\left(g\left(x\right)\right)$:
Rule:$\frac{d}{dx}\left(f\left(g\left(x\right)\right)={f}^{\prime }\left(g\left(x\right)\right){g}^{\prime }\left(x\right)$
Example:$\frac{d}{dx}\left(\mathrm{sin}\left(x\right){\right)}^{2}=2\left(\mathrm{sin}\left(x\right)\right)\mathrm{cos}\left(x\right)$

## 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$.
$\frac{d}{dx}\left({x}^{2}\right)=2x$
But of course, we could use any other letter.
$\frac{d}{da}\left({a}^{2}\right)=2a$
What if we did something crazy, and replaced $x$ with a function instead of another letter.
$\frac{d}{d\left(\mathrm{sin}\left(x\right)\right)}\left(\mathrm{sin}\left(x\right){\right)}^{2}=2\mathrm{sin}\left(x\right)$
It's unclear exactly what this $\frac{d}{d\left(\mathrm{sin}\left(x\right)\right)}$ symbol would mean, but let's just go with it for a second. We can imagine multiplying it by $\frac{d\left(\mathrm{sin}\left(x\right)\right)}{dx}$ to "cancel out" the $d\left(\mathrm{sin}\left(x\right)\right)$ term:
$\frac{d\left(\mathrm{sin}\left(x\right){\right)}^{2}}{\overline{)d\left(\mathrm{sin}\left(x\right)\right)}}\cdot \frac{\overline{)d\left(\mathrm{sin}\left(x\right)\right)}}{dx}=\frac{d}{dx}\left(\mathrm{sin}\left(x\right){\right)}^{2}$
This is not really a mathematically legitimate thing to do, since these "$dx$" and "$d\left(\mathrm{sin}\left(x\right)\right)$" 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 $\frac{d}{dx}\left(\mathrm{sin}\left(x\right){\right)}^{2}$ like this, we know what each individual term is, even if we don't know how to take the derivative of $\left(\mathrm{sin}\left(x\right){\right)}^{2}$:
This trick looks particularly clean when we write it in the abstract, rather than with the specific case of ${x}^{2}$ and $\mathrm{sin}\left(x\right)$:
$\overline{)\frac{d}{dx}\left[f\left(g\left(x\right)\right)\right]=\frac{df}{dg}\cdot \frac{dg}{dx}}$

## 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 $\sqrt{{x}^{2}}$. For example, $|-5|=\sqrt{\left(-5{\right)}^{2}}=\sqrt{25}=5$

## Arbitrarily long composition

The chain rule can apply to composing multiple functions, not just two. For example, suppose $A\left(x\right)$, $B\left(x\right)$, $C\left(x\right)$ and $D\left(x\right)$ are four different functions, and define $f$ to be their composition:
$f\left(x\right)=A\left(B\left(C\left(D\left(x\right)\right)\right)\right)$
Using the $\frac{df}{dx}$ notation for the derivative, we can apply the chain rule as:
$\frac{df}{dx}=\frac{d}{dx}A\left(B\left(C\left(D\left(x\right)\right)\right)=\frac{dA}{dB}\cdot \frac{dB}{dC}\cdot \frac{dC}{dD}\cdot \frac{dD}{dx}$
Using ${f}^{\prime }$ notation, we get more of a snowman aesthetic:
${f}^{\prime }\left(x\right)={A}^{\prime }\left(B\left(C\left(D\left(x\right)\right)\right)\right)\cdot {B}^{\prime }\left(C\left(D\left(x\right)\right)\right)\cdot {C}^{\prime }\left(D\left(x\right)\right)\cdot {D}^{\prime }\left(x\right)$

## Example 4:

Suppose $f\left(x\right)=\mathrm{sin}\left({e}^{{x}^{2}+x}\right)$.
We think of $f$ as being the composition of
$\begin{array}{rl}A\left(x\right)& =\mathrm{sin}\left(x\right)\\ B\left(x\right)& ={e}^{x}\\ C\left(x\right)& ={x}^{2}+x\end{array}$
Where the derivative of each function is
$\begin{array}{rl}{A}^{\prime }\left(x\right)& =\mathrm{cos}\left(x\right)\\ {B}^{\prime }\left(x\right)& ={e}^{x}\\ {C}^{\prime }\left(x\right)& =2x+1\end{array}$
According to the chain rule, the derivative of the composition is
$\begin{array}{rl}{f}^{\prime }\left(x\right)& ={A}^{\prime }\left(B\left(C\left(x\right)\right)\right)\cdot {B}^{\prime }\left(C\left(x\right)\right)\cdot {C}^{\prime }\left(x\right)\\ & \\ & =\overline{)\mathrm{cos}\left({e}^{{x}^{2}+x}\right)\cdot {e}^{{x}^{2}+x}\cdot \left(2x+1\right)}\end{array}$

## Want to join the conversation?

• I just finished this tutorial about the Chain Rule by watching all videos and solving all given problems; and now im confused at this overview. At the very first Introduction they mention "We also know how to take the derivative of their product:". I watched all videos and solved tens of problems and never heard or faced any problem like that. Looks like they will introduce it in next tutorials about "Taking Derivatives" or what? Please HELP !
• Following the videos in order as presented on this website does in fact make that statement confusing.

The rule in question is the "Power Rule" and those videos are presented in a section or two after the chain rule videos.
• Is there a more detailed lesson on the derivative of |x|?
• Note that f(x) = |x| is not differentiable at x=0
The easiest way to do this is by rewriting |x|
|x| = √(x²) (this is the principal square root only, do not simplify at this point)
d/dx √(x²)
= d/dx (x²)^(½)
= ½ (x²)^(−½) ∙ d/dx (x²)
= ½ (x²)^(−½) ∙ (2x)
Rearranging:
= ½ (2x)∙ (x²)^(−½)
=(x)∙ (x²)^(−½)
= (x)÷(x²)^(−½)
= x ÷ |x|
This is a piecewise function:
f'(x) =  −1, for x < 0          1, for x > 0f'(x) is undefined at x=0
• On the last example, we can treat x^2+x as a function. But why we cannot treat 2 in x^2 as a function?
• While you can treat "2" as a function, namely the constant function f(x) = 2 that outputs 2 for all inputs, raising one function to the power of another like f(x)^g(x) is different from composing functions, as in f(g(x)). For example, the chain rule cannot be used to take the derivative of x^x.
(1 vote)
• It appears that examples one and two are the same.
• The two problems are different because of the position of the ^2 symbol. The sin function is being squared in example 1, and x is being squared in example 2.
(1 vote)
• I'm appalled by this violent abuse of notation. What did that derivative ever do to you?
• if u=f(x^2-y^2,2xy) , find (partial^2u/partial x^2)
let r=x^2-y^2
t=2xy
how can i get this partial ??
• By partial you mean the partial derivative of u with respect to x ?
• I want to how to differentiate :y=√cosx+√cosx+√cosx+....∞ prove dy∕dx= sinx/1-2y.
I wanna know how to differentiate infinite series.?HELP!!
(1 vote)
• First check your final expression it needs parenthesis to be readable.
Both cos(x) and sqrt(x) have infinite series representation.
You can take the derivative into a series term by term.
But it looks like you can rewrite your series using some form of e^(ln(g(x))) or the like where g(x) is your original series.
I suggest rewriting using lim (n-> inf) g(x)
Then use facts like e^a * e^b = e^(a+b)
and ln(a* b* c*) = ln a + ln b + ln (c)
and for any power series that you can write down taking the derivative of the term by term
is equivalent to integrating the derivative (look in the section)" operations on power series"
• Nah, keeping in mind some of the, to be entirely frank, sadistic exercises I had as an assignment last year during calculus, I'd call that "Fake Algebra" section something like "Cancer Calculus"
• In the Practice: Differentiate composite functions I have a problem. I can't understand when 'v' is the outside part and when 'u' is the inside part of the function. In every exercise they change and I am getting confused.
(1 vote)
• For that purpose there is a rule of thumb.
ILATE

I - Inverse trigonometric(sin^-1 , cos^-1 , etc.
L - Logarithmic (log)
A - Arithmatic (x^n , n is a real no.)
T - Trigonometric (sin, cos , etc.)
E - Exponential ( a^x)

The function coming first (from left to right ) is taken to be 'u' and other one is taken to be 'v'.

Hope that helps :)