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.

## AP®︎/College Calculus AB

### Course: AP®︎/College Calculus AB>Unit 3

Lesson 1: The chain rule: introduction

# Chain rule

The chain rule tells us how to find the derivative of a composite function. Brush up on your knowledge of composite functions, and learn how to apply the chain rule correctly.
The chain rule says:
$\frac{d}{dx}\left[f\left(g\left(x\right)\right)\right]={f}^{\prime }\left(g\left(x\right)\right){g}^{\prime }\left(x\right)$
It tells us how to differentiate composite functions.

## Quick review of composite functions

A function is composite if you can write it as $f\left(g\left(x\right)\right)$. In other words, it is a function within a function, or a function of a function.
For example, $\mathrm{cos}\left({x}^{2}\right)$ is composite, because if we let $f\left(x\right)=\mathrm{cos}\left(x\right)$ and $g\left(x\right)={x}^{2}$, then $\mathrm{cos}\left({x}^{2}\right)=f\left(g\left(x\right)\right)$.
$g$ is the function within $f$, so we call $g$ the "inner" function and $f$ the "outer" function.
On the other hand, $\mathrm{cos}\left(x\right)\cdot {x}^{2}$ is not a composite function. It is the product of $f\left(x\right)=\mathrm{cos}\left(x\right)$ and $g\left(x\right)={x}^{2}$, but neither of the functions is within the other one.
Problem 1
Is $g\left(x\right)=\mathrm{ln}\left(\mathrm{sin}\left(x\right)\right)$ a composite function? If so, what are the "inner" and "outer" functions?

### Common mistake: Not recognizing whether a function is composite or not

Usually, the only way to differentiate a composite function is using the chain rule. If we don't recognize that a function is composite and that the chain rule must be applied, we will not be able to differentiate correctly.
On the other hand, applying the chain rule on a function that isn't composite will also result in a wrong derivative.
Especially with transcendental functions (e.g., trigonometric and logarithmic functions), students often confuse compositions like $\mathrm{ln}\left(\mathrm{sin}\left(x\right)\right)$ with products like $\mathrm{ln}\left(x\right)\mathrm{sin}\left(x\right)$.
Problem 2
Is $h\left(x\right)={\mathrm{cos}}^{2}\left(x\right)$ a composite function? If so, what are the "inner" and "outer" functions?

Want more practice? Try this exercise.

### Common mistake: Wrong identification of the inner and outer function

Even when a student recognized that a function is composite, they might get the inner and the outer functions wrong. This will surely end in a wrong derivative.
For example, in the composite function ${\mathrm{cos}}^{2}\left(x\right)$, the outer function is ${x}^{2}$ and the inner function is $\mathrm{cos}\left(x\right)$. Students are often confused by this sort of function and think that $\mathrm{cos}\left(x\right)$ is the outer function.

## Worked example of applying the chain rule

Let's see how the chain rule is applied by differentiating $h\left(x\right)=\left(5-6x{\right)}^{5}$. Notice that $h$ is a composite function:
Because $h$ is composite, we can differentiate it using the chain rule:
$\frac{d}{dx}\left[f\left(g\left(x\right)\right)\right]={f}^{\prime }\left(g\left(x\right)\right)\cdot {g}^{\prime }\left(x\right)$
Described verbally, the rule says that the derivative of the composite function is the inner function $g$ within the derivative of the outer function ${f}^{\prime }$, multiplied by the derivative of the inner function ${g}^{\prime }$.
Before applying the rule, let's find the derivatives of the inner and outer functions:
$\begin{array}{rl}{g}^{\prime }\left(x\right)& =-6\\ \\ {f}^{\prime }\left(x\right)& =5{x}^{4}\end{array}$
Now let's apply the chain rule:
$\begin{array}{rl}& \frac{d}{dx}\left[f\left(g\left(x\right)\right)\right]\\ \\ =& {f}^{\prime }\left(g\left(x\right)\right)\cdot {g}^{\prime }\left(x\right)\\ \\ =& 5\left(5-6x{\right)}^{4}\cdot -6\\ \\ =& -30\left(5-6x{\right)}^{4}\end{array}$

### Practice applying the chain rule

Problem 3.A
Problem set 3 will walk you through the steps of differentiating $\mathrm{sin}\left(2{x}^{3}-4x\right)$.
What are the inner and outer functions in $\mathrm{sin}\left(2{x}^{3}-4x\right)$?

Problem 4
$\frac{d}{dx}\left[\sqrt{\mathrm{cos}\left(x\right)}\right]=\phantom{\rule{0.167em}{0ex}}?$

Want more practice? Try this exercise.
Problem 5
$x$$f\left(x\right)$$h\left(x\right)$${f}^{\prime }\left(x\right)$${h}^{\prime }\left(x\right)$
$-1$$9$$-1$$-5$$-6$
$2$$3$$-1$$1$$6$
$G\left(x\right)=f\left(h\left(x\right)\right)$
${G}^{\prime }\left(2\right)=$

Want more practice? Try this exercise.
Problem 6
Katy tried to find the derivative of $\left(2{x}^{2}-4{\right)}^{3}$. Here is her work:
Step 1: Let $f\left(x\right)={x}^{3}$ and $g\left(x\right)=2{x}^{2}-4$, then $\left(2{x}^{2}-4{\right)}^{3}=f\left(g\left(x\right)\right)$.
Step 2: ${f}^{\prime }\left(x\right)=3{x}^{2}$
Step 3: The derivative is ${f}^{\prime }\left(g\left(x\right)\right)$:
$\frac{d}{dx}\left[\left(2{x}^{2}-4{\right)}^{3}\right]=3\left(2{x}^{2}-4{\right)}^{2}$
Is Katy's work correct? If not, what's her mistake?

### Common mistake: Forgetting to multiply by the derivative of the inner function

A common mistake is for students to only differentiate the outer function, which results in ${f}^{\prime }\left(g\left(x\right)\right)$, while the correct derivative is ${f}^{\prime }\left(g\left(x\right)\right){g}^{\prime }\left(x\right)$.

### Another common mistake: Computing ${f}^{\prime }\left({g}^{\prime }\left(x\right)\right)$‍

Another common mistake is to differentiate $f\left(g\left(x\right)\right)$ as the composition of the derivatives, ${f}^{\prime }\left({g}^{\prime }\left(x\right)\right)$.
This is also incorrect. The function that should be inside of ${f}^{\prime }\left(x\right)$ is $g\left(x\right)$, not ${g}^{\prime }\left(x\right)$.
Remember: The derivative of $f\left(g\left(x\right)\right)$ is ${f}^{\prime }\left(g\left(x\right)\right){g}^{\prime }\left(x\right)$. Not ${f}^{\prime }\left(g\left(x\right)\right)$ and not ${f}^{\prime }\left({g}^{\prime }\left(x\right)\right)$.

## Want to join the conversation?

• Why are sin(x), cos(x), etc, called transcendental functions?
• On Problem 2. I chose the answer "not a composite function" because i took cos^2(x) to be cos(x)*cos(x) and hence used the product rule to differentiate. Is that okay?
• Yes, applying the chain rule and applying the product rule are both valid ways to take a derivative in Problem 2.

The placement of the problem on the page is a little misleading. Immediately before the problem, we read, "students often confuse compositions ... with products".

This suggests that the problem we are about to work (Problem 2) will teach us the difference between compositions and products, but, surprisingly, cos^2(x) is both a composition _and_ a product.

You can see this by plugging the following two lines into Wolfram Alpha (one at a time) and clicking "step-by-step-solution":
d/dx sin(x)cos(x)
d/dx cos(x)cos(x)

For d/dx sin(x)cos(x), W.A. applies the product rule. For d/dx cos(x)cos(x), W.A. recognizes that we can rewrite as a composition d/dx cos^2(x) and apply the chain rule.

In summary, there are some functions that can be written only as compositions, like d/dx ln(cos(x)). There are other functions that can be written only as products, like d/dx sin(x)cos(x). And there are other functions that can be written both as products and as compositions, like d/dx cos(x)cos(x).
• how do you know when to use chain rule?
• One uses the chain rule when differentiating a function that can be expressed as a function of a function.
eg sin(x²) or ln(arctan(x))
• Why is it called the chain rule?
• Why is the derivative of 3x = 3, but the derivative of 3(sin x) = 3(cos x)?
• The derivative gives you a rate of change or to put it more simply the gradient of a function.

Since the rate change varies it is not the same. Like 3x =y, has a constant gradient of 3. But 3sinx has a gradient of 3cos(x) which depends on x which is not constant.
• can u not see [cos (x)]^2 as a composite function, but see it as: cos (x)*cos (x), and use the product rule to find the derivative (using both chain rule and product rule ends up the same derivative)? thx!
• Yep! You can do that. And as you said, you'll get the same answer in both cases (-2sin(x)cos(x))
• One thing that has been a little bit shaky with me is what can we define as its own function. I understand cos(x^2) being defined as f(x) = cos(x) and g(x) = x^2, but can we say cos(x) is also a composite function?

In that example,f(x) = cos(x) and g(x) = x then we solve with the chain rule. If we can, I'm assuming it's redundant, but I'm just looking for a "line" of when we can and can't define new functions. Also, can we combine different "instances" (sorry for the poor terminology) of variables as ONE unique function?

For example, if we had f(x) = (x^2)(cos(x))(sin(x)), could we combine (x^2) and cos(x) to be one function? so, g(x) = (x^2)(cos(x)) and h(x) = sin(x). If so, then could we apply the product rule with those two functions (one of which being a combination of both (x^2) and cos(x))? So, f(x) = (g(x))(h(x))

Sorry about the long question, I am just hoping for a more clear picture of when we can assign variables as their own function. Thanks.
• That's the beauty of it: we can describe variables as separate functions however we like. We can say that x² is the function f(x)=x² composed with g(x)=x, and applying chain rule gives us
f'(g(x))·g'(x)
g'(x)=1, and g(x)=x, so this simplifies to
f'(x)
which is 2x.

Or we can rewrite x as e^(ln(x)). Then chain rule gives the derivative of x as
e^(ln(x))·(1/x), or x/x, or 1.

For your product rule example, yes we could consider x²cos(x) to be a single function, and in fact it would be convenient to do so, since we only know how to apply the product rule to products of two functions. By doing this, we find the derivative to be

d/dx[x²cos(x)]·sin(x)+(x²cos(x))·cos(x)

and now we can simplify this by computing the derivative of x²cos(x) using the product rule again.

There is no "line". We can divvy up expressions, introduce multiplications by 1, or write simple variables as compositions of inverse functions however we like, however makes the problem more convenient to solve.
• Can someone kindly help me on how to differentiate (x-11)^3 / (x+3) using the chain rule?
TIA
(1 vote)
• You'll need quotient or product rule in addition to the chain rule.

First let's find the derivative of (x-11)³. Outer function is x³, inner function is x-11. So we take
d/dx((x-11)³)
d/(x-11) (x-11)³ •d/dx (x-11)
3(x-11)²•1
3(x-11)²

Now, the derivative of x+3 is just 1. Putting these together with the quotient rule, we get
d/dx ((x-11)³/(x+3))
[(x+3)•d/dx(x-11)³ -(x-11)³•d/dx(x+3)]/((x+3)²)
Substitute the derivatives that we know and we get
[(x+3)•3(x-11)² -(x-11)³•1]/((x+3)²)
This is our answer. To simplify, we can factor an (x-11)² out of the numerator and get
(x-11)²•(3x+9 -(x-11))/((x+3)²)
(x-11)²•(2x+20)/((x+3)²)
• Can you please make a video on how to find the minimum value of 2^sin(x) + 2^cos(x). Also, what is the inner function and outer function for 2^sin(x)??
Thanks, any help would be appreciated
• While the AM-GM inequality is useful, I'm just going to do it as a standard optimization problem.

Because you asked, inner function is sin(x) and outer function is 2^x.

f(x) = 2^(sin x) + 2^(cos x)
f'(x) = ln(2) * 2^(sin x) * cos x - ln(2) * 2^(cos x) * sin x
This is undefined nowhere, so we look for points where f'(x) = 0, or 2^(sin x) cos x = 2^(cos x) sin x; this expression is (essentially) equivalent to sin(x) = cos(x), which is true at pi/4 + k * pi.
The minimum value of f should be at 5pi/4, where (sin x, cos x) = (-sqrt(2) / 2, -sqrt(2) / 2).

min(f(x)) = f(5pi / 4 + 2pi * k) = 1.225.