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.
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))\).
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.
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.
Write \(u=h(x)\) and calculate \(h'(x)\).
Write \(v=g(u)\) and calculate \(g'(u)\), keeping its input \(u\) visible.
Write \(y=f(v)\) and calculate \(f'(v)\).
Use \(f'(v)g'(u)h'(x)\), then substitute the expressions for \(u\) and \(v\).
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:
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,
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,
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\).
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.
- Write \(y=((x+1)^2+4)^3\) in the form \(f(g(h(x)))\), naming the inner, middle, and outer functions.
- For \(y=((x^2+3)^2+1)^2\), state the three derivative factors before simplifying their product.
- What differentiability conditions are needed to use the three-layer chain rule at \(x\)?
- Explain why differentiating only the outermost power does not give the derivative of a nested expression.
- Differentiate \(y=((2x-1)^2+3)^2\), and check your result by evaluating the layer rates at \(x=1\).