The Chain Rule
Differentiate composite functions—the most powerful rule
You already use chain-rule thinking every day, even if you have never heard the term. When you check the weather and think, “It’s getting colder because the sun is setting,” you are linking two rates of change: temperature depends on sunlight, and sunlight depends on time. The chain rule is simply the mathematical machinery for connecting these linked rates. Once you see the pattern, you will wonder how you ever managed without it.
This lesson will show you how to differentiate composite functions—functions built by plugging one function inside another. The chain rule is arguably the most powerful differentiation technique you will learn, because real-world quantities almost always depend on other quantities in layered ways. Master this rule, and you unlock the ability to handle exponentials, trigonometric expressions, nested powers, and far more.
Core Concepts
What Is a Composite Function?
Before diving into derivatives, let us make sure we are comfortable with composite functions themselves. A composite function is what you get when you feed the output of one function into the input of another.
Suppose you have two functions:
- $g(x) = x^2$ (the “inner” function)
- $f(u) = \sin(u)$ (the “outer” function)
The composite function $(f \circ g)(x)$ means “first apply $g$, then apply $f$”:
$$(f \circ g)(x) = f(g(x)) = f(x^2) = \sin(x^2)$$
Notice the order carefully: $g$ acts first (it is “inside”), and $f$ acts on the result (it is “outside”). Think of it like putting on socks and then shoes—the socks go on first, but the shoes are what the world sees on the outside.
The Problem: How Do We Differentiate Composites?
You already know how to differentiate $\sin(x)$ and $x^2$ separately. But what about $\sin(x^2)$? You cannot simply differentiate the outer function and ignore what is inside. The derivative of $\sin(x^2)$ is not $\cos(x^2)$.
Here is the intuition: when you differentiate $\sin(u)$ with respect to $u$, you get $\cos(u)$. But if $u$ itself is changing (because $u = x^2$ depends on $x$), then you need to account for how fast $u$ is changing too. The chain rule tells you exactly how to do this.
The Chain Rule: Two Equivalent Forms
Function notation: $$\frac{d}{dx}[f(g(x))] = f’(g(x)) \cdot g’(x)$$
In words: differentiate the outer function (keeping the inner function unchanged), then multiply by the derivative of the inner function.
Leibniz notation: $$\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}$$
This version looks like the $du$’s “cancel,” and while that is not quite rigorous, it is an excellent memory aid. If $y$ depends on $u$, and $u$ depends on $x$, then the rate of change of $y$ with respect to $x$ is the product of the two individual rates.
Identifying Outer and Inner Functions
The key skill in applying the chain rule is recognizing the composite structure. Ask yourself: “What is the outermost operation, and what is its input?”
Example: For $y = (3x + 7)^5$:
- The outermost operation is “raise something to the 5th power”
- The “something” (the inner function) is $3x + 7$
- So $f(u) = u^5$ and $g(x) = 3x + 7$
Example: For $y = e^{x^2}$:
- The outermost operation is “take $e$ to a power”
- The exponent (the inner function) is $x^2$
- So $f(u) = e^u$ and $g(x) = x^2$
Example: For $y = \sqrt{\sin(x)}$:
- The outermost operation is “take the square root”
- The thing inside the square root is $\sin(x)$
- So $f(u) = \sqrt{u}$ and $g(x) = \sin(x)$
A Step-by-Step Process
Here is a reliable method for applying the chain rule:
- Identify the composite structure. Find the outer function $f$ and the inner function $g(x)$.
- Differentiate the outer function as if the inner part were just a single variable. This gives you $f’(g(x))$.
- Multiply by the derivative of the inner function. Compute $g’(x)$ and multiply.
- Simplify if desired.
Let us apply this to $y = \sin(x^2)$:
- Outer: $f(u) = \sin(u)$. Inner: $g(x) = x^2$.
- $f’(u) = \cos(u)$, so $f’(g(x)) = \cos(x^2)$.
- $g’(x) = 2x$.
- Answer: $\frac{dy}{dx} = \cos(x^2) \cdot 2x = 2x\cos(x^2)$.
Combining the Chain Rule with Other Rules
Real problems often require using the chain rule alongside the product rule or quotient rule. The key is to work systematically from the outside in.
Chain Rule + Product Rule:
If $y = f(x) \cdot g(x)$ where $f$ or $g$ (or both) require the chain rule, use the product rule first, then apply the chain rule to each piece.
Chain Rule + Quotient Rule:
Similarly, if $y = \frac{f(x)}{g(x)}$ and the numerator or denominator involves a composition, use the quotient rule for the overall structure, then the chain rule for the individual pieces.
Nested Compositions: Multiple Chain Rules
Sometimes you have a function inside a function inside a function. For example: $$y = \sin(\cos(x^2))$$
Here you have three layers:
- Outermost: $\sin(\square)$
- Middle: $\cos(\square)$
- Innermost: $x^2$
You apply the chain rule repeatedly, working from the outside in:
$$\frac{dy}{dx} = \cos(\cos(x^2)) \cdot \frac{d}{dx}[\cos(x^2)]$$
Now apply the chain rule again to $\frac{d}{dx}[\cos(x^2)]$:
$$= \cos(\cos(x^2)) \cdot (-\sin(x^2)) \cdot 2x$$
$$= -2x \sin(x^2) \cos(\cos(x^2))$$
The pattern extends: each time you “peel off” one layer, you multiply by the derivative of what remains inside.
Notation and Terminology
| Term | Meaning | Example |
|---|---|---|
| Composite function | A function formed by applying one function to the output of another | $\sin(x^2)$, where $\sin$ is applied to the output of $x^2$ |
| Outer function | The “wrapper” function—the last operation performed | In $\sin(x^2)$, the outer function is $\sin(\square)$ |
| Inner function | The “filling”—the function whose output becomes the input | In $\sin(x^2)$, the inner function is $x^2$ |
| Chain rule | The rule $(f \circ g)’(x) = f’(g(x)) \cdot g’(x)$ for differentiating composites | |
| Leibniz form | $\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}$ | If $y = u^3$ and $u = 2x + 1$, then $\frac{dy}{dx} = 3u^2 \cdot 2 = 6(2x+1)^2$ |
| Nested composition | A composite of three or more functions | $e^{\sin(x^2)}$ has three layers |
Examples
Example 1: A Simple Power Composition
Problem: Find $\frac{d}{dx}[(x + 1)^5]$.
Solution:
This is a composition where something is raised to the 5th power.
- Outer function: $f(u) = u^5$
- Inner function: $g(x) = x + 1$
Applying the chain rule:
$$\frac{d}{dx}[(x + 1)^5] = 5(x + 1)^4 \cdot \frac{d}{dx}[x + 1]$$
$$= 5(x + 1)^4 \cdot 1$$
$$= 5(x + 1)^4$$
Key insight: The derivative of the inner function $(x + 1)$ is just 1, so it does not change the answer much here. But you must still account for it—the chain rule always applies.
Example 2: A Linear Inner Function
Problem: Find $\frac{d}{dx}[(3x - 2)^4]$.
Solution:
- Outer function: $f(u) = u^4$
- Inner function: $g(x) = 3x - 2$
Applying the chain rule:
$$\frac{d}{dx}[(3x - 2)^4] = 4(3x - 2)^3 \cdot \frac{d}{dx}[3x - 2]$$
$$= 4(3x - 2)^3 \cdot 3$$
$$= 12(3x - 2)^3$$
Key insight: The coefficient 3 from the inner derivative “pops out” and multiplies the whole expression. This is why $(3x - 2)^4$ and $(x - 2)^4$ have different derivatives even though they look similar.
Example 3: A Square Root Composition
Problem: Find $\frac{d}{dx}[\sqrt{x^2 + 1}]$.
Solution:
First, rewrite the square root as a power: $\sqrt{x^2 + 1} = (x^2 + 1)^{1/2}$.
- Outer function: $f(u) = u^{1/2}$
- Inner function: $g(x) = x^2 + 1$
Applying the chain rule:
$$\frac{d}{dx}[(x^2 + 1)^{1/2}] = \frac{1}{2}(x^2 + 1)^{-1/2} \cdot \frac{d}{dx}[x^2 + 1]$$
$$= \frac{1}{2}(x^2 + 1)^{-1/2} \cdot 2x$$
$$= \frac{2x}{2(x^2 + 1)^{1/2}}$$
$$= \frac{x}{\sqrt{x^2 + 1}}$$
Key insight: Converting roots to fractional powers makes the chain rule easier to apply. The power rule works the same way whether the exponent is a whole number or a fraction.
Example 4: Chain Rule Combined with Product Rule
Problem: Find $\frac{d}{dx}[(x^2 + 1)^3(x - 1)^2]$.
Solution:
This is a product of two functions, each of which requires the chain rule. We apply the product rule first:
$$\frac{d}{dx}[u \cdot v] = u’v + uv’$$
where $u = (x^2 + 1)^3$ and $v = (x - 1)^2$.
Finding $u’$ (using chain rule): $$u’ = 3(x^2 + 1)^2 \cdot 2x = 6x(x^2 + 1)^2$$
Finding $v’$ (using chain rule): $$v’ = 2(x - 1)^1 \cdot 1 = 2(x - 1)$$
Combining with the product rule: $$\frac{d}{dx}[(x^2 + 1)^3(x - 1)^2] = 6x(x^2 + 1)^2 \cdot (x - 1)^2 + (x^2 + 1)^3 \cdot 2(x - 1)$$
Factoring (optional but nice):
Both terms share common factors of $2(x^2 + 1)^2(x - 1)$:
$$= 2(x^2 + 1)^2(x - 1)[3x(x - 1) + (x^2 + 1)]$$
$$= 2(x^2 + 1)^2(x - 1)[3x^2 - 3x + x^2 + 1]$$
$$= 2(x^2 + 1)^2(x - 1)(4x^2 - 3x + 1)$$
Key insight: When combining rules, work systematically. Apply the “big picture” rule (product or quotient) first, then use the chain rule for each piece.
Example 5: Chain Rule with a Quotient Inside
Problem: Find $\frac{d}{dx}\left[\left(\frac{x}{x+1}\right)^4\right]$.
Solution:
This is a composition: something raised to the 4th power, where that something is a quotient.
- Outer function: $f(u) = u^4$
- Inner function: $g(x) = \frac{x}{x+1}$
First, we need $g’(x)$ using the quotient rule:
$$g’(x) = \frac{(x+1) \cdot 1 - x \cdot 1}{(x+1)^2} = \frac{x + 1 - x}{(x+1)^2} = \frac{1}{(x+1)^2}$$
Now apply the chain rule:
$$\frac{d}{dx}\left[\left(\frac{x}{x+1}\right)^4\right] = 4\left(\frac{x}{x+1}\right)^3 \cdot \frac{1}{(x+1)^2}$$
Simplifying:
$$= \frac{4x^3}{(x+1)^3} \cdot \frac{1}{(x+1)^2}$$
$$= \frac{4x^3}{(x+1)^5}$$
Key insight: The chain rule does not care what the inner function looks like. It could be a polynomial, a quotient, a trig function—anything. You just need its derivative.
Example 6: A Triple Composition
Problem: Find $\frac{d}{dx}[e^{\sin(2x)}]$.
Solution:
This has three layers:
- Outermost: $e^{\square}$
- Middle: $\sin(\square)$
- Innermost: $2x$
We apply the chain rule twice, working from outside to inside:
$$\frac{d}{dx}[e^{\sin(2x)}] = e^{\sin(2x)} \cdot \frac{d}{dx}[\sin(2x)]$$
Now differentiate $\sin(2x)$ using the chain rule again:
$$\frac{d}{dx}[\sin(2x)] = \cos(2x) \cdot 2 = 2\cos(2x)$$
Putting it together:
$$\frac{d}{dx}[e^{\sin(2x)}] = e^{\sin(2x)} \cdot 2\cos(2x) = 2\cos(2x) \cdot e^{\sin(2x)}$$
Key insight: With nested compositions, you get a product of derivatives—one factor for each “layer” you peel off. The number of factors equals the depth of nesting.
Example 7: Trigonometric Composition with Simplification
Problem: Find $\frac{d}{dx}[\tan^2(x)]$.
Solution:
Note that $\tan^2(x)$ means $[\tan(x)]^2$, not $\tan(x^2)$.
- Outer function: $f(u) = u^2$
- Inner function: $g(x) = \tan(x)$
Applying the chain rule:
$$\frac{d}{dx}[\tan^2(x)] = 2\tan(x) \cdot \sec^2(x)$$
This can also be written as:
$$= 2\tan(x)\sec^2(x) = \frac{2\sin(x)}{\cos(x)} \cdot \frac{1}{\cos^2(x)} = \frac{2\sin(x)}{\cos^3(x)}$$
Key insight: Be careful with notation. The expression $\sin^2(x)$ means $[\sin(x)]^2$, which is a composition. The outer function is “squaring,” and the inner function is “sine.”
Key Properties and Rules
The Chain Rule Formula (Both Forms)
Prime notation: $$[f(g(x))]’ = f’(g(x)) \cdot g’(x)$$
Leibniz notation: $$\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}$$
Common Patterns to Memorize
These patterns come up so often that it is worth knowing them by heart:
| Function | Derivative |
|---|---|
| $[g(x)]^n$ | $n[g(x)]^{n-1} \cdot g’(x)$ |
| $e^{g(x)}$ | $e^{g(x)} \cdot g’(x)$ |
| $\ln(g(x))$ | $\frac{g’(x)}{g(x)}$ |
| $\sin(g(x))$ | $\cos(g(x)) \cdot g’(x)$ |
| $\cos(g(x))$ | $-\sin(g(x)) \cdot g’(x)$ |
| $\tan(g(x))$ | $\sec^2(g(x)) \cdot g’(x)$ |
The “Outside-In” Principle
When differentiating a composite function:
- Start with the outermost function
- Differentiate it, leaving the inside alone
- Multiply by the derivative of the next layer in
- Repeat until you reach the innermost function
Combining Rules: Order of Operations
When a problem requires multiple differentiation rules:
- Product of composites: Product rule first, chain rule for each factor
- Quotient of composites: Quotient rule first, chain rule for numerator and denominator
- Composition of products: Chain rule first, product rule for the inner function
The Chain Rule Extends
For a composition of $n$ functions: $$\frac{d}{dx}[f_1(f_2(f_3(\cdots f_n(x))))] = f_1’(f_2(\cdots)) \cdot f_2’(f_3(\cdots)) \cdot \cdots \cdot f_n’(x)$$
Each derivative is evaluated at the appropriate composition.
Real-World Applications
Temperature and Altitude
Imagine you are hiking up a mountain. The temperature $T$ depends on your altitude $h$, and your altitude depends on the time $t$ you have been hiking. If you want to know how fast the temperature is changing with respect to time, you need the chain rule:
$$\frac{dT}{dt} = \frac{dT}{dh} \cdot \frac{dh}{dt}$$
For instance, if temperature drops by $2°C$ per 100 meters of altitude gain, and you are climbing at 50 meters per minute:
$$\frac{dT}{dt} = \left(-\frac{2°C}{100 \text{ m}}\right) \cdot \left(\frac{50 \text{ m}}{\text{min}}\right) = -1°C/\text{min}$$
The temperature you feel is dropping at 1 degree per minute.
Gear Ratios and Mechanical Systems
In a car’s transmission, engine speed and wheel speed are linked through gear ratios. If the engine spins at rate $\omega_e$ and the gear ratio is $r$, then wheel speed is $\omega_w = r \cdot \omega_e$. The rate of change of wheel speed with respect to time involves the chain rule:
$$\frac{d\omega_w}{dt} = r \cdot \frac{d\omega_e}{dt}$$
This is why shifting to a lower gear (higher $r$) gives you more acceleration—the same engine acceleration produces a larger wheel acceleration.
Population Dynamics
In ecology, a predator population $P$ might depend on a prey population $N$, which in turn depends on time $t$ as seasons change. The rate of change of the predator population with respect to time is:
$$\frac{dP}{dt} = \frac{dP}{dN} \cdot \frac{dN}{dt}$$
This captures how changes in prey availability (due to seasonal fluctuations) propagate through to predator populations.
Unit Conversions and Rate Changes
Suppose you know how a quantity changes with respect to one unit, and you want to convert to another unit. For example, if you know fuel efficiency in miles per gallon and want to find it in kilometers per liter:
The chain rule underlies the conversion: $\frac{d(\text{km})}{d(\text{L})} = \frac{d(\text{km})}{d(\text{mi})} \cdot \frac{d(\text{mi})}{d(\text{gal})} \cdot \frac{d(\text{gal})}{d(\text{L})}$
Financial Models
In economics, profit $P$ might depend on quantity sold $Q$, which depends on price $p$, which depends on time $t$ (due to inflation or market conditions). The chain rule connects all these rates:
$$\frac{dP}{dt} = \frac{dP}{dQ} \cdot \frac{dQ}{dp} \cdot \frac{dp}{dt}$$
This helps businesses understand how time-dependent market changes affect their bottom line.
Self-Test Problems
Problem 1: Find $\frac{d}{dx}[(2x + 5)^7]$.
Show Answer
Using the chain rule with outer function $u^7$ and inner function $2x + 5$:
$$\frac{d}{dx}[(2x + 5)^7] = 7(2x + 5)^6 \cdot 2 = 14(2x + 5)^6$$
Problem 2: Find $\frac{d}{dx}[\cos(3x^2)]$.
Show Answer
Outer function: $\cos(u)$. Inner function: $3x^2$.
$$\frac{d}{dx}[\cos(3x^2)] = -\sin(3x^2) \cdot 6x = -6x\sin(3x^2)$$
Problem 3: Find $\frac{d}{dx}[e^{-x^2}]$.
Show Answer
Outer function: $e^u$. Inner function: $-x^2$.
$$\frac{d}{dx}[e^{-x^2}] = e^{-x^2} \cdot (-2x) = -2xe^{-x^2}$$
This is related to the famous Gaussian (bell curve) function used in statistics.
Problem 4: Find $\frac{d}{dx}[\ln(x^2 + 4)]$.
Show Answer
Outer function: $\ln(u)$. Inner function: $x^2 + 4$.
$$\frac{d}{dx}[\ln(x^2 + 4)] = \frac{1}{x^2 + 4} \cdot 2x = \frac{2x}{x^2 + 4}$$
Problem 5: Find $\frac{d}{dx}[\sqrt{1 - x^2}]$.
Show Answer
Rewrite as $(1 - x^2)^{1/2}$. Outer function: $u^{1/2}$. Inner function: $1 - x^2$.
$$\frac{d}{dx}[(1 - x^2)^{1/2}] = \frac{1}{2}(1 - x^2)^{-1/2} \cdot (-2x) = \frac{-x}{\sqrt{1 - x^2}}$$
This derivative appears in the study of circles and inverse trigonometric functions.
Problem 6: Find $\frac{d}{dx}[\sin^3(x)]$.
Show Answer
Remember that $\sin^3(x) = [\sin(x)]^3$. Outer function: $u^3$. Inner function: $\sin(x)$.
$$\frac{d}{dx}[\sin^3(x)] = 3\sin^2(x) \cdot \cos(x) = 3\sin^2(x)\cos(x)$$
Problem 7: Find $\frac{d}{dx}[(x^3 - 2x)^4]$.
Show Answer
Outer function: $u^4$. Inner function: $x^3 - 2x$.
$$\frac{d}{dx}[(x^3 - 2x)^4] = 4(x^3 - 2x)^3 \cdot (3x^2 - 2) = 4(3x^2 - 2)(x^3 - 2x)^3$$
Problem 8: Find $\frac{d}{dx}[e^{\cos(x)}]$.
Show Answer
This is a composition of two functions. Outer: $e^u$. Inner: $\cos(x)$.
$$\frac{d}{dx}[e^{\cos(x)}] = e^{\cos(x)} \cdot (-\sin(x)) = -\sin(x) \cdot e^{\cos(x)}$$
Problem 9: Find $\frac{d}{dx}\left[\frac{1}{(x^2 + 1)^3}\right]$.
Show Answer
Rewrite as $(x^2 + 1)^{-3}$. Outer function: $u^{-3}$. Inner function: $x^2 + 1$.
$$\frac{d}{dx}[(x^2 + 1)^{-3}] = -3(x^2 + 1)^{-4} \cdot 2x = \frac{-6x}{(x^2 + 1)^4}$$
Problem 10 (Challenge): Find $\frac{d}{dx}[\ln(\sin(e^x))]$.
Show Answer
This has three layers. Working outside to inside:
- Outermost is $\ln(u)$, derivative is $\frac{1}{u} = \frac{1}{\sin(e^x)}$
- Next layer is $\sin(v)$, derivative is $\cos(v) = \cos(e^x)$
- Innermost is $e^x$, derivative is $e^x$
Multiplying all the pieces:
$$\frac{d}{dx}[\ln(\sin(e^x))] = \frac{1}{\sin(e^x)} \cdot \cos(e^x) \cdot e^x = \frac{e^x \cos(e^x)}{\sin(e^x)} = e^x \cot(e^x)$$
Summary
-
Composite functions are built by applying one function to the output of another: $(f \circ g)(x) = f(g(x))$.
-
The chain rule tells us how to differentiate composites: $$\frac{d}{dx}[f(g(x))] = f’(g(x)) \cdot g’(x)$$
-
In Leibniz notation, the chain rule looks like: $\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dx}$.
-
To apply the chain rule, identify the outer and inner functions. The outer function is the last operation performed; the inner function is its input.
-
Differentiate from outside to inside: first differentiate the outer function (keeping the inner unchanged), then multiply by the derivative of the inner function.
-
The chain rule combines with other rules. For products or quotients of compositions, use the product or quotient rule first, then apply the chain rule to each piece.
-
For nested compositions (three or more layers), apply the chain rule repeatedly—you get one factor for each layer.
-
Common patterns like $[g(x)]^n$, $e^{g(x)}$, and $\ln(g(x))$ appear frequently. Recognizing them speeds up your work.
-
The chain rule has countless applications: physics (related rates), engineering (gear systems), biology (population dynamics), economics (linked variables), and anywhere quantities depend on each other in layers.
-
The chain rule is often called the most important differentiation rule because most real-world functions are compositions. Once you master it, you can differentiate almost anything.