Tutorials › Calculus I › Differentiating Three-Layer Compositions

Product, Quotient, and Chain Rules · Tutorial 461 of 1495

Differentiating Three-Layer Compositions

Identify the inner, middle, and outer functions in a three-layer composition, then apply the chain rule successively and check the resulting derivative.

Intermediate 9 min read

What You'll Learn

  • Identify inner, middle, and outer functions in a nested expression
  • State when the three-layer chain rule applies
  • Differentiate each layer and multiply the factors in the correct order
  • Keep intermediate functions visible to avoid missing a factor
  • Check a derivative by evaluating layer rates or by expanding a manageable expression
  • Recognize and correct the mistake of omitting an inner derivative

Why Three Layers Need Careful Organization

A nested expression can contain several familiar functions, but its derivative depends on how those functions are composed. For example, in \(((x^2+1)^3+2)^4\), the variable is first used to form \(x^2+1\). That result is raised to the third power and shifted by \(2\). Finally, the new result is raised to the fourth power.

Each step is a layer. The chain rule says that the derivative of the full expression combines the derivatives of all the layers. The main challenge is to keep track of which derivative belongs to which layer, and to include every factor.

Key idea: For a three-layer composition, differentiate the outer function, then the middle function, then the inner function. Multiply those three derivatives, evaluating each at the output of the layer inside it.

Definition and Formula

Let \(h\) be the inner function, \(g\) the middle function, and \(f\) the outer function. A three-layer composition has the form \(y=f(g(h(x)))\). The function \(h\) acts directly on \(x\); \(g\) acts on the result \(h(x)\); and \(f\) acts on the result \(g(h(x))\).

Definition: A three-layer composition is a function \(y=f(g(h(x)))\), formed by applying \(h\), then \(g\), then \(f\). If \(h\) is differentiable at \(x\), \(g\) is differentiable at \(h(x)\), and \(f\) is differentiable at \(g(h(x))\), then the chain rule gives $$ \frac{dy}{dx} = f'(g(h(x)))\,g'(h(x))\,h'(x). $$

The inputs to the derivatives matter. The outer derivative \(f'\) is evaluated at the output of the middle layer, \(g(h(x))\). The middle derivative \(g'\) is evaluated at the output of the inner layer, \(h(x)\). The inner derivative \(h'\) is evaluated at \(x\).

It is often helpful to give the intermediate outputs names. Set \(u=h(x)\) and \(v=g(u)\), so that \(y=f(v)\). Then the calculation is organized as \(\frac{dy}{dx}=\frac{dy}{dv}\frac{dv}{du}\frac{du}{dx}\). This compact notation records the same order of factors as the formula above.

Why the Three Factors Appear

The formula follows by applying the ordinary chain rule twice. First treat \(v=g(h(x))\) as a single inner function of \(y=f(v)\). Differentiating the outer composition gives \(\frac{dy}{dx}=f'(v)\frac{dv}{dx}\). Then apply the chain rule to \(v=g(h(x))\), giving \(\frac{dv}{dx}=g'(h(x))h'(x)\). Substituting this into the first equation yields the three-factor formula.

$$ \begin{aligned} \frac{dy}{dx} &= f'(v)\frac{dv}{dx}\\ &= f'(g(h(x)))\left(g'(h(x))h'(x)\right)\\ &= f'(g(h(x)))\,g'(h(x))\,h'(x). \end{aligned} $$

Each application requires differentiability at the relevant input: the outer function at \(g(h(x))\), the middle function at \(h(x)\), and the inner function at \(x\). If these conditions hold, the two chain-rule applications are valid, so their substitution proves the three-layer formula.

A Reliable Layer-by-Layer Process

Before differentiating, rewrite the expression so that each layer is visible. Then differentiate one layer at a time, keeping the outputs of the inner layers in place until the factors have been assembled.

1
Name the inner layer.
Write \(u=h(x)\) and calculate \(h'(x)\).
2
Name the middle layer.
Write \(v=g(u)\) and calculate \(g'(u)\), keeping its input \(u\) visible.
3
Name the outer layer.
Write \(y=f(v)\) and calculate \(f'(v)\).
4
Multiply in the chain-rule order.
Use \(f'(v)g'(u)h'(x)\), then substitute the expressions for \(u\) and \(v\).
5
Check the result.
Confirm that each layer contributed one derivative factor, and use a numerical or expanded check when practical.

Worked Examples

Worked Example: A Power of a Shifted Power

Differentiate \(y=((x^2+1)^3+2)^4\). Identify the three layers by setting \(u=x^2+1\), \(v=u^3+2\), and \(y=v^4\).

Differentiate the inner layer: \(u=x^2+1\), so \(\frac{du}{dx}=2x\). Differentiate the middle layer with respect to its input: \(v=u^3+2\), so \(\frac{dv}{du}=3u^2\). Differentiate the outer layer: \(y=v^4\), so \(\frac{dy}{dv}=4v^3\).

Multiply the three rates in order and substitute the layer expressions:

$$ \begin{aligned} \frac{dy}{dx} &=\frac{dy}{dv}\frac{dv}{du}\frac{du}{dx}\\ &=4v^3\cdot 3u^2\cdot 2x\\ &=24x\,u^2v^3\\ &=24x(x^2+1)^2\bigl((x^2+1)^3+2\bigr)^3. \end{aligned} $$

For a numerical check at \(x=1\), the layers give \(u=1^2+1=2\), \(v=2^3+2=10\), and \(y=10^4=10000\). The rates are \(\frac{du}{dx}=2\), \(\frac{dv}{du}=3(2)^2=12\), and \(\frac{dy}{dv}=4(10)^3=4000\). Their product is \(4000\cdot12\cdot2=96000\). Substituting \(x=1\) in the derivative formula also gives \(24\cdot1\cdot2^2\cdot10^3=96000\).

Worked Example: A Linear Expression Inside a Squared Layer

Differentiate \(y=\bigl((3x-1)^2+2\bigr)^3\). Take \(u=(3x-1)^2\), \(v=u+2\), and \(y=v^3\).

The inner derivative is \(\frac{du}{dx}=2(3x-1)\cdot3=6(3x-1)\). The middle derivative is \(\frac{dv}{du}=1\). The outer derivative is \(\frac{dy}{dv}=3v^2\). Therefore,

$$ \begin{aligned} \frac{dy}{dx} &=3v^2\cdot1\cdot6(3x-1)\\ &=18(3x-1)v^2\\ &=18(3x-1)\bigl((3x-1)^2+2\bigr)^2. \end{aligned} $$

Check at \(x=1\). Then \(3x-1=2\), \(u=2^2=4\), \(v=4+2=6\), and \(y=6^3=216\). The three rates are \(\frac{du}{dx}=6(2)=12\), \(\frac{dv}{du}=1\), and \(\frac{dy}{dv}=3(6)^2=108\). Their product is \(108\cdot1\cdot12=1296\). The displayed derivative at \(x=1\) gives \(18\cdot2\cdot6^2=1296\), as required for this numerical check.

Worked Example: Checking by Expansion

Differentiate \(y=\bigl((x+2)^2-1\bigr)^2\). Use \(u=x+2\), \(v=u^2-1\), and \(y=v^2\). These are three distinct layers: a shift, a squared expression with a subtraction, and an outer square.

The inner derivative is \(\frac{du}{dx}=1\). The middle derivative is \(\frac{dv}{du}=2u\). The outer derivative is \(\frac{dy}{dv}=2v\). Thus,

$$ \begin{aligned} \frac{dy}{dx} &=2v\cdot2u\cdot1\\ &=4uv\\ &=4(x+2)\bigl((x+2)^2-1\bigr). \end{aligned} $$

For a full algebraic check, first simplify the original function: \((x+2)^2-1=x^2+4x+3\). Hence \(y=(x^2+4x+3)^2=x^4+8x^3+22x^2+24x+9\). Differentiating this expanded polynomial gives \(\frac{dy}{dx}=4x^3+24x^2+44x+24\). Expanding the chain-rule result gives \(4(x+2)(x^2+4x+3)=4(x^3+6x^2+11x+6)=4x^3+24x^2+44x+24\). The two derivatives agree.

Common Mistake: Stopping at the Outer Derivative

A frequent error is to differentiate only the outermost power. For the first example, writing \(\frac{dy}{dx}=4((x^2+1)^3+2)^3\) accounts for the derivative of the fourth power, but treats its input as though it had derivative \(1\). That is not true: the input \((x^2+1)^3+2\) also changes with \(x\).

The correction is to include the middle and inner rates. The middle layer contributes \(3(x^2+1)^2\), and the inner layer contributes \(2x\). Thus the full derivative is \(4((x^2+1)^3+2)^3\cdot3(x^2+1)^2\cdot2x\), which simplifies to \(24x(x^2+1)^2((x^2+1)^3+2)^3\).

Takeaway: Do not stop after differentiating the outer function. Trace the input of that function back through every layer, multiplying by the derivative of each layer along the way.

Why Layer Names Help

When an expression is written without intermediate names, it can be difficult to see whether a factor has been omitted. The temporary variables \(u\) and \(v\) make the dependencies explicit: \(x\) determines \(u\), \(u\) determines \(v\), and \(v\) determines \(y\). The derivative follows that same dependency chain in reverse, from the outer rate to the inner rate.

The layers need not all be powers. A layer may be a polynomial, a constant shift, or another differentiable function. What matters is that the full expression can be written as \(f(g(h(x)))\), and that each function is differentiable at the input where it is used. This approach applies specifically to a composition; sums and products within a layer may also require their own differentiation rules.

For a quick final check, ask three questions: Have I identified three functions whose composition is the original expression? Did I differentiate each one with respect to its own input? Did I multiply all three rates? These checks do not replace the differentiability conditions, but they catch many organizational errors.

Check Your Understanding

For each question, identify the layers clearly before calculating.

  1. Write \(y=((x+1)^2+4)^3\) in the form \(f(g(h(x)))\), naming the inner, middle, and outer functions.
  2. For \(y=((x^2+3)^2+1)^2\), state the three derivative factors before simplifying their product.
  3. What differentiability conditions are needed to use the three-layer chain rule at \(x\)?
  4. Explain why differentiating only the outermost power does not give the derivative of a nested expression.
  5. Differentiate \(y=((2x-1)^2+3)^2\), and check your result by evaluating the layer rates at \(x=1\).

Test yourself: Calculus I final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon