Access this content offline
Omniguides
Skip to the reading

The Chain Rule

This original textbook reading covers part of the AP topic. Follow the AP course outline for complete topic instruction and practice.

This reading includes verified answer corrections and explicitly stated clarifications.

Why another rule?

It seems like we have learned how to take the derivative of every imaginable function, doesn’t it? However, we are still missing a few more techniques. So far we have learned how to take the derivative of a function divided by another function (quotient rule), a function multiplied by another function (product rule), and the derivative of polynomial functions in general (power rule). There has been something missing though. All of our functions have been in the form of y=sin(x) or y=ex. How would we find the derivative of a function such as y=sin(x2)? Or the derivative of esin(cos(x))? We can’t, at least not yet. That is because these are functions composed within other functions, and we have not learned how to take their derivatives yet. In order to take the derivatives of these functions, we need the help of the chain rule, which says that for any function F(x)=f(g(h(…(x)))), its derivative is represented by F′(x)=f′(g(h(…(x)))⋅g′(h(…(x)))⋅(h′(…(x))

The ‘...’ just represents other functions that might be present like j(x), etc. The easiest way to think of the chain rule is like peeling an onion layer by layer. We first take the derivative of the outside layer (function), then multiply it by the derivative of the layer underneath, then multiply by the derivative of the layer underneath that one. We peel apart the function layer by layer, starting with the outermost layer, and hope it will not make us cry. Let’s try a practice problem to see how this works.

Example 4.3.1

Find the derivative of y=ex2 using the chain rule

Interactive 4.3.1 Visualizing the Chain Rule

Interactive 4.3.1 Visualizing the Chain Rule
Read all original figure notes

Function approaches +∞

Notice that the function is approaching ∞ really fast! So fast that the derivative increases even faster than the base function. If we were to zoom out, this function would look something like a frog’s tongue, long and narrow.

Derivative = 0

Notice that when the slope of the tangent line to the parent function equals 0, the derivative function crosses the y-axis.

.

Using the chain rule formula, we can rewrite this as y=eg(x). Therefore,

dydx=ddxeg(x)⋅ddxg(x). If we consider now that g(x)= x2, we can see that dydx=ex2⋅2x

The chain rule is probably the second-hardest derivative concept to grasp. So perhaps a picture will help convince you that this is indeed true. Refer to Interactive 4.3.1.

Example Problem 4.3.2

Differentiate y=xcos(sin(x))

This one needs an extra tool: the exponent cos(sin x) changes with x, so the ordinary constant-exponent power rule does not apply. For x > 0, let y = xcos(sin x) and take natural logs: ln y = cos(sin x) ln x.

Differentiate both sides using the product and chain rules: y′/y = −sin(sin x) cos x ln x + cos(sin x)/x. The minus sign comes from differentiating cosine, and the second term comes from differentiating ln x.

Now multiply by y and replace y with the original expression. Both terms are needed because both the base and the exponent change.

y′=xcos(sin(x))(cos(sin(x))x−sin(sin(x))⋅cos(x)⋅ln(x)), for x > 0.

Example Problem 4.3.3

Find the derivative of y=x⋅ecos(x2)sinx

This is probably going to be one of the hardest derivatives we have taken so far, combining the product, quotient, power, and chain rules all in one. Try to follow along very carefully. We start off with the quotient rule. We choose f(x)=x⋅ecos(x2) and g(x)=sinx, so that:

dydx=sinx⋅ddx(x⋅ecos(x2))-x⋅ecos(x2)⋅ddx(sinx)sin2x

One of the derivatives above we can easily do. The other one requires using both the product rule and chain rule. Let’s solve the harder one separately, starting out with the product rule.ddx(x⋅ecos(x2))=x⋅ddxecos(x2)+1⋅ecos(x2)=x⋅ecos(x2)ddxcos(x2)+ecos(x2)=x⋅ecos(x2)(-sin(x2))ddxx2+ecos(x2)=-2x2⋅ecos(x2)⋅sin(x2)+ecos(x2)

dydx=sinx⋅(-2x2⋅ecos(x2)⋅sin(x2)+ecos(x2))-x⋅ecos(x2)⋅(cosx)sin2x

Notice that ecos(x2) is present in all three terms in the numerator. We can factor this out.

dydx=ecosx2(sinx(-2x2sin(x2)+1)-xcosx)sin2x

Note: Since that was a very difficult derivative, let’s enjoy this beautiful gallery of graphs that shows just how colorful math can be... moving on!

Interactive 4.3.2 The hardest derivative ever (so far)

Interactive 4.3.2 The hardest derivative ever (so far)
Read all original figure notes

A hole with limit e

The original function F(x) = x ecos(x²)/sin(x) is undefined at x = 0 because its denominator is 0. But limx→0 x/sin(x) = 1 and ecos(x²) → e, so its limit is e ≈2.71828. If we explicitly define F(0) =e, we obtain a continuous extension. The value at the hole and the limit are different questions.

When is the derivative = 0?

Notice that the graph of the derivative function that we calculated crosses y=0 whenever the tangent line to the green function would have a slope of 0. This seems to be a pretty good indicator that we have the right derivative.

Pop Quiz 4.3.1 Chain Rule Review

Question 1 of 5 · 0 correct

How many functions are composed within ex in the function f(x)=e3cos(tan(x2))?

Select one answer.
Glossary and deeper reading · 3 refreshers

These editorial refreshers supplement the reading. Definitions and examples are added guidance; original source wording and recorded answers remain in their original context.

  • Derivative

    A derivative gives the instantaneous rate of change of a function with respect to its input. At a point, it is the finite limit of the difference quotient when that limit exists. For example, the derivative of x² is 2x, so the tangent slope at x=3 is 6. A derivative function collects those rates across the inputs where the function is differentiable.

    Read more: 2.2 · Derivative →

  • Function

    A mathematical function assigns exactly one output to each input in its domain. Inputs can share an output, but one input cannot have two different outputs. For example, f(x)=x² assigns the output 9 to both 3 and −3. Function notation names the rule and its input; f(3) means the output when the input is 3.

  • Chain rule

    The chain rule differentiates a composition by multiplying the outer derivative at the inner output by the inner derivative. For differentiable functions, (f(g(x)))′=f′(g(x))g′(x). For example, the derivative of sin(x²) is cos(x²)·2x. Nested compositions require a factor for each successive layer.

    Read more: 3.1 · Chain rule →

Search lessons, terms and problems