Why Three Nested Functions Need Two Chain Rule Applications
A function can be built by feeding the output of one function into another. With three functions, the output of the innermost function becomes the input of the middle function, and that output becomes the input of the outermost function. Keeping track of these inputs is essential when differentiating.
For example, in \(f(g(h(x)))\), the function \(h\) acts first, then \(g\), and finally \(f\). The derivative must account for how a change in \(x\) passes through all three stages. The Chain Rule handles one composition at a time, so we apply it twice.
Composition and the Required Inputs
Let \(h\) map an input \(x\) to \(h(x)\), let \(g\) map that result to \(g(h(x))\), and let \(f\) map the final result to \(f(g(h(x)))\). It is useful to name the two compositions that appear along the way:
In this notation, \(q\) is the inner two-function composition, while \(F\) is the full three-function composition. To differentiate \(F\) at a particular \(x\), the functions must be differentiable at the points where they are used: \(h\) at \(x\), \(g\) at \(h(x)\), and \(f\) at \(g(h(x))\).
The evaluation points matter. The derivative \(h'(x)\) is evaluated at the original input. The derivative \(g'(h(x))\) is evaluated at the output of \(h\). The derivative \(f'(g(h(x)))\) is evaluated at the output of \(g\circ h\). Each derivative is taken with respect to the input of its own function.
Deriving the Three-Function Chain Rule
We can obtain the formula by applying the two-function Chain Rule first to \(F=f\circ q\), and then to \(q=g\circ h\). The first application treats the entire expression \(g(h(x))\) as the input to \(f\). The second differentiates that inner expression.
Set \(q(x)=g(h(x))\), so \(F(x)=f(q(x))\).
By the Chain Rule, \(F'(x)=f'(q(x))q'(x)\).
Since \(q(x)=g(h(x))\), another Chain Rule application gives \(q'(x)=g'(h(x))h'(x)\).
Replace \(q(x)\) and \(q'(x)\) in the formula for \(F'(x)\).
Substitution gives the result:
This derivation explains why there are three factors: one derivative for each function through which the input passes. It also explains their evaluation points. The result of the inner function supplies the input for the middle derivative; the result of the first two functions supplies the input for the outer derivative.
The factors are written from the outermost derivative to the innermost derivative. Since these are ordinary real-valued factors, their multiplication can be rearranged numerically. However, keeping the displayed order helps preserve the relationship between each derivative and its input.
Worked Examples
Worked Example: A Three-Layer Polynomial at a Point
Let \(f(u)=u^2+1\), \(g(v)=3v-2\), and \(h(x)=x^2+1\). Find the derivative of \(f(g(h(x)))\) at \(x=1\).
First evaluate the functions in their order of composition. The innermost value is \(h(1)=1^2+1=2\). Next, \(g(h(1))=g(2)=3(2)-2=4\).
The derivative factors are \(f'(u)=2u\), \(g'(v)=3\), and \(h'(x)=2x\). Their required values are \(f'(4)=2(4)=8\), \(g'(2)=3\), and \(h'(1)=2(1)=2\). Therefore,
To check, simplify the composition: \(g(h(x))=3(x^2+1)-2=3x^2+1\), so \(f(g(h(x)))=(3x^2+1)^2+1\). Differentiating gives \(2(3x^2+1)(6x)=12x(3x^2+1)\). At \(x=1\), this is \(12(1)(4)=48\), as required.
Worked Example: A Cubic Outer Function
Let \(f(u)=u^3\), \(g(v)=v^2+1\), and \(h(x)=2x-1\). Find the derivative of \(f(g(h(x)))\) at \(x=1\).
Evaluate the function layers: \(h(1)=2(1)-1=1\), \(g(h(1))=g(1)=1^2+1=2\). The derivative functions are \(f'(u)=3u^2\), \(g'(v)=2v\), and \(h'(x)=2\). Thus \(f'(2)=3(2^2)=12\), \(g'(1)=2(1)=2\), and \(h'(1)=2\). Multiplying the factors gives
For a check, the full composition is \(\big((2x-1)^2+1\big)^3\). Its derivative, using the Chain Rule, is \(3\big((2x-1)^2+1\big)^2\cdot 2(2x-1)\cdot 2\). At \(x=1\), the inner quantity is \(2\) and \(2x-1=1\), so the derivative is \(3(2^2)\cdot 2(1)\cdot 2=12\cdot 2\cdot 2=48\). The two calculations agree.
Worked Example: Tracking Each Input at a Different Value
Let \(f(u)=5u-4\), \(g(v)=v^2\), and \(h(x)=x^3-1\). Find the derivative of \(f(g(h(x)))\) at \(x=2\).
The function values are \(h(2)=2^3-1=8-1=7\), then \(g(h(2))=g(7)=7^2=49\). The derivative functions are \(f'(u)=5\), \(g'(v)=2v\), and \(h'(x)=3x^2\). At the relevant inputs, \(f'(49)=5\), \(g'(7)=2(7)=14\), and \(h'(2)=3(2^2)=12\). Therefore,
To check, \(f(g(h(x)))=5(x^3-1)^2-4\). Its derivative is \(5\cdot 2(x^3-1)\cdot 3x^2=30x^2(x^3-1)\). At \(x=2\), this equals \(30(4)(7)=120(7)=840\). This agrees with the three-factor calculation.
A Common Error: Losing One of the Stages
A frequent error is to differentiate the outer function and the middle function, but stop before accounting for how the innermost function changes with \(x\). Consider the first worked example. An incomplete calculation might be
This is not the derivative with respect to \(x\): it leaves out \(h'(x)=2x\). The corrected calculation is
At \(x=1\), the incomplete expression gives \(24\), while the correct derivative is \(48\). A useful check is to count the functions in the composition: for this three-function composition, the derivative formula must include one factor from each of the three functions.
Why the Evaluation Points Matter
The formula is not just a product of three derivative expressions. Each derivative must be evaluated at the correct stage of the composition. If the inputs are misidentified, the factors may be numerically wrong even when all three derivative functions have been found correctly.
For \(f(g(h(x)))\), follow the values from the inside outward: start with \(x\), compute \(h(x)\), then \(g(h(x))\). The derivative \(h'(x)\) uses the starting value; \(g'(h(x))\) uses the first output; and \(f'(g(h(x)))\) uses the second output. Substituting these inputs before multiplying is a reliable way to avoid confusion.
The same organization is useful when differentiating symbolically. First identify the outer, middle, and inner functions. Then write one derivative factor for each layer, with its input shown. This keeps the composition structure visible even when the resulting expression is complicated.
Summary
To differentiate a composition of three functions, apply the Chain Rule to the outer function and the remaining inner composition, then apply it again to the inner composition. Provided each function is differentiable at the point where it is used, the result is
Read the expression from outside to inside: the outer derivative is evaluated at \(g(h(x))\), the middle derivative at \(h(x)\), and the inner derivative at \(x\). Keeping those inputs attached to their derivatives gives a systematic derivation and a dependable way to check the calculation.
Check Your Understanding
For each question, identify the function inputs carefully before evaluating any derivative factors.
- State the differentiability conditions needed to apply the three-function Chain Rule at \(x\).
- If \(f(u)=u^2\), \(g(v)=v+1\), and \(h(x)=3x\), write the derivative of \(f(g(h(x)))\) as a product of three factors. Do not simplify it.
- For \(f(u)=u^3\), \(g(v)=2v\), and \(h(x)=x^2\), evaluate the three derivative factors at \(x=1\) and find their product.
- In \(f(g(h(x)))\), at what input is \(g'\) evaluated? At what input is \(f'\) evaluated?
- Explain why differentiating only \(f\) and \(g\) does not generally give the derivative with respect to \(x\).