← MathScape

Nested Chain Rule

MATH161
Reference: Stewart 2.5  •  Chapter: 2  •  Section: 5

Navigation: Wiki Home > Skills > Nested Chain Rule

The Nested Chain Rule

When Functions Have Three or More Layers

What's the derivative of $\sin(\cos(\tan x))$? This function has three layers:

The basic chain rule handles two functions composed together. For three or more, we extend the idea: peel away one layer at a time, multiplying the derivatives as we go.

The name "chain rule" really makes sense here—we're building a chain of derivatives, linking outer to middle to inner.

Prerequisite Map

This skill
Nested Chain Rule

Quick Reference

Property Value
Concept Differentiation Rules
Chapter Ch 3, §4
Difficulty Advanced
Time ~15 minutes

Key Concepts

The Extended Chain Rule

For a composition of three functions $y = f(g(h(x)))$:

$$\boxed{\frac{dy}{dx} = f'(g(h(x))) \cdot g'(h(x)) \cdot h'(x)}$$

In Leibniz notation with $y = f(u)$, $u = g(v)$, $v = h(x)$:

$$\frac{dy}{dx} = \frac{dy}{du} \cdot \frac{du}{dv} \cdot \frac{dv}{dx}$$

The "Outside-In" Strategy

Work from the outermost function inward:

  1. Differentiate the outer function, keeping everything inside unchanged
  2. Multiply by the derivative of the next layer, keeping the rest unchanged
  3. Continue until you reach $x$
y = sin(cos(tan x))
    ├── outer: sin(□)
    │       └── middle: cos(□)
    │              └── inner: tan x

Step 1: cos(cos(tan x))           [derivative of outer at inner]
Step 2: × (-sin(tan x))           [derivative of middle at its inner]
Step 3: × sec²x                    [derivative of innermost]

Visualizing the Layers

┌─────────────────────────────────┐
│  Outer: f                       │  ← Differentiate first
│  ┌───────────────────────────┐  │
│  │  Middle: g                 │  │  ← Differentiate second
│  │  ┌─────────────────────┐   │  │
│  │  │  Inner: h(x)        │   │  │  ← Differentiate third
│  │  └─────────────────────┘   │  │
│  └───────────────────────────┘  │
└─────────────────────────────────┘

Result: f'(g(h(x))) · g'(h(x)) · h'(x)

How to Identify the Layers

Ask yourself: "In what order would I compute this for a specific $x$?"

Example: $\sqrt{\sec(x^3)}$

To compute at $x = 2$:

  1. First compute $x^3 = 8$ (innermost)
  2. Then compute $\sec(8)$ (middle)
  3. Then compute $\sqrt{\sec(8)}$ (outermost)

So the layers are: $\sqrt{\square}$, then $\sec(\square)$, then $x^3$.

Common Nested Patterns

Function Outer Middle Inner Derivative
$\sin^2(3x)$ $(\square)^2$ $\sin(\square)$ $3x$ $2\sin(3x)\cos(3x) \cdot 3 = 6\sin(3x)\cos(3x)$
$\cos(\tan(x^2))$ $\cos(\square)$ $\tan(\square)$ $x^2$ $-\sin(\tan(x^2)) \cdot \sec^2(x^2) \cdot 2x$
$\sqrt{1 + \sin x}$ $\sqrt{\square}$ none $1 + \sin x$ $\frac{1}{2\sqrt{1+\sin x}} \cdot \cos x$

Practice Problems

Level 1 Identifying Layers

For the function $f(x) = \cos^3(2x)$, identify the outer, middle, and inner functions.

Thought Process

First, rewrite $\cos^3(2x)$ as $[\cos(2x)]^3$ to see the structure clearly.

Now ask: what's done last? The cubing. What's done before that? The cosine. What's done first? The multiplication by 2.

Show Answer

Rewrite: $f(x) = [\cos(2x)]^3$

  • Outer: $u^3$ (cubing function)
  • Middle: $\cos(v)$ (cosine function)
  • Inner: $2x$ (linear function)
Level 2 Three-Layer Chain Rule

Find the derivative of $y = \sin^2(4x)$.

Thought Process

Rewrite as $y = [\sin(4x)]^2$.

Layers:

  • Outer: $(\square)^2$, derivative: $2(\square)$
  • Middle: $\sin(\square)$, derivative: $\cos(\square)$
  • Inner: $4x$, derivative: $4$

Multiply them all together, evaluating outer and middle at their respective inputs.

Show Answer

Let $y = [\sin(4x)]^2$

$$\frac{dy}{dx} = 2[\sin(4x)]^1 \cdot \cos(4x) \cdot 4$$

$$= 8\sin(4x)\cos(4x)$$

Using the double-angle identity $2\sin\theta\cos\theta = \sin(2\theta)$:

$$= 4\sin(8x)$$

Level 3 Nested with Square Root

Differentiate $f(x) = \sqrt{\tan(x^2 + 1)}$.

Thought Process

Rewrite as $[\tan(x^2 + 1)]^{1/2}$.

Three layers:

  1. Outer: $(\square)^{1/2}$ → derivative: $\frac{1}{2}(\square)^{-1/2}$
  2. Middle: $\tan(\square)$ → derivative: $\sec^2(\square)$
  3. Inner: $x^2 + 1$ → derivative: $2x$
Show Answer

$$f(x) = [\tan(x^2 + 1)]^{1/2}$$

$$f'(x) = \frac{1}{2}[\tan(x^2 + 1)]^{-1/2} \cdot \sec^2(x^2 + 1) \cdot 2x$$

$$= \frac{x \sec^2(x^2 + 1)}{\sqrt{\tan(x^2 + 1)}}$$

Level 4 Four Layers Deep

Find $\frac{dy}{dx}$ for $y = \sin(\cos(\tan(\sec x)))$.

Thought Process

This has four layers. Work outside-in:

  1. $\sin(\square)$ → $\cos(\square)$
  2. $\cos(\square)$ → $-\sin(\square)$
  3. $\tan(\square)$ → $\sec^2(\square)$
  4. $\sec(x)$ → $\sec(x)\tan(x)$

At each step, evaluate the derivative at the appropriate inner expression.

Show Answer

Let $u_1 = \sec x$, $u_2 = \tan(u_1)$, $u_3 = \cos(u_2)$, $y = \sin(u_3)$.

$$\frac{dy}{dx} = \frac{dy}{du_3} \cdot \frac{du_3}{du_2} \cdot \frac{du_2}{du_1} \cdot \frac{du_1}{dx}$$

Computing each:

  • $\frac{dy}{du_3} = \cos(u_3) = \cos(\cos(\tan(\sec x)))$
  • $\frac{du_3}{du_2} = -\sin(u_2) = -\sin(\tan(\sec x))$
  • $\frac{du_2}{du_1} = \sec^2(u_1) = \sec^2(\sec x)$
  • $\frac{du_1}{dx} = \sec x \tan x$

$$\frac{dy}{dx} = \cos(\cos(\tan(\sec x))) \cdot [-\sin(\tan(\sec x))] \cdot \sec^2(\sec x) \cdot \sec x \tan x$$

$$= -\cos(\cos(\tan(\sec x))) \sin(\tan(\sec x)) \sec^2(\sec x) \sec x \tan x$$

Level 5 Deriving a Formula for Triple Compositions

Let $F(x) = f(g(h(x)))$ where $f$, $g$, and $h$ are differentiable functions. Given the following values:

Value at relevant point
$h(1)$ $2$
$g(2)$ $3$
$h'(1)$ $4$
$g'(2)$ $5$
$f'(3)$ $6$

Find $F'(1)$.

Thought Process

Use the extended chain rule: $$F'(x) = f'(g(h(x))) \cdot g'(h(x)) \cdot h'(x)$$

At $x = 1$:

  • $h(1) = 2$, so $g(h(1)) = g(2) = 3$
  • Therefore $f'(g(h(1))) = f'(3) = 6$
  • And $g'(h(1)) = g'(2) = 5$
  • And $h'(1) = 4$
Show Answer

By the extended chain rule: $$F'(1) = f'(g(h(1))) \cdot g'(h(1)) \cdot h'(1)$$

Tracing through:

  • $h(1) = 2$
  • $g(h(1)) = g(2) = 3$

So: $$F'(1) = f'(3) \cdot g'(2) \cdot h'(1)$$ $$= 6 \cdot 5 \cdot 4$$ $$= 120$$

CCI-Style Conceptual Questions

Conceptual Order of Operations in the Chain Rule

When differentiating $\sin^2(\ln x)$, which function should you differentiate first?

  1. $\ln x$ (the innermost function)
  2. $\sin(\square)$ (the middle function)
  3. $(\square)^2$ (the outermost function)
  4. It doesn't matter what order you use
Thought Process

The chain rule works "outside-in"—you always start by differentiating the outermost layer while treating everything inside as a single unit.

Think of it like peeling an onion: you remove the outer layer first.

Show Answer

(C) The outermost function $(\square)^2$

The chain rule always proceeds from outside to inside. You differentiate the outer layer first (treating everything inside as a unit), then multiply by the derivative of the next layer, and so on.

For $[\sin(\ln x)]^2$: $$\frac{d}{dx} = 2[\sin(\ln x)]^1 \cdot \cos(\ln x) \cdot \frac{1}{x}$$ $$= \frac{2\sin(\ln x)\cos(\ln x)}{x}$$

Mastery Checklist

Mental Model

The Assembly Line:

Picture a factory assembly line with three machines in sequence. Raw material ($x$) goes in one end:

If you want to know how a small change in raw material affects the final product, you multiply the "sensitivity" of each machine:

$$\text{Total effect} = \text{Machine 3 sensitivity} \times \text{Machine 2 sensitivity} \times \text{Machine 1 sensitivity}$$

Each machine's sensitivity is its derivative, evaluated at whatever input it actually receives.


Connections

Looking back:

Looking ahead:


Previous Up Next
Generalized Power Rule Skills Index Implicit Differentiation

Last updated: 2026-01-22