Why Deep Compositions Need a Systematic Method
A function can be built by feeding the output of one function into another, then feeding that output into still another. For example, in \(e^{\sin(x^2)}\), the input \(x\) is first squared, the result is passed to sine, and the sine value becomes the exponent of the exponential function.
The chain rule handles one such layer. For three or more layers, the same rule is applied repeatedly. The essential discipline is to keep track of every intermediate function: each layer contributes a derivative factor, and omitting even one factor changes the answer.
Representing the Layers
Suppose a function is written as \(y=F(G(H(x)))\). Its layers, from inside to outside, are \(H\), then \(G\), then \(F\). To differentiate, name the intermediate outputs:
The chain rule gives \(\frac{dy}{dx}=\frac{dy}{dv}\frac{dv}{du}\frac{du}{dx}\). In prime notation, the same calculation is \(y'=F'(G(H(x)))G'(H(x))H'(x)\). The derivative factors appear in the same order as the successive local rates, from the outer output back to the original input.
It is often useful to write the intermediate functions before differentiating. This makes it visible which input belongs inside each derivative. For instance, \(F'\) is evaluated at \(G(H(x))\), not at \(x\), and \(G'\) is evaluated at \(H(x)\).
Worked Example: Exponential of a Sine of a Square
Worked Example: Differentiate \(e^{\sin(x^2)}\)
Let \(y=e^{\sin(x^2)}\). Identify three layers by setting \(u=x^2\), \(v=\sin u\), and \(y=e^v\). The intermediate derivatives are \(\frac{du}{dx}=2x\), \(\frac{dv}{du}=\cos u\), and \(\frac{dy}{dv}=e^v\).
Multiply these rates and then substitute the intermediate expressions: $$ \frac{dy}{dx} = \frac{dy}{dv}\frac{dv}{du}\frac{du}{dx} = e^v\cos u(2x) = 2x e^{\sin(x^2)}\cos(x^2). $$
Check: Starting at \(x\), the local rate for the square is \(2x\); at \(u=x^2\), the rate for sine is \(\cos(x^2)\); at \(v=\sin(x^2)\), the rate for the exponential is \(e^{\sin(x^2)}\). Their product is exactly the stated derivative, with all three layers represented.
Worked Example: A Nested Trigonometric Composition
Worked Example: Differentiate \(\cos(\sin(2x+1))\)
There are three layers: \(u=2x+1\), \(v=\sin u\), and \(y=\cos v\). Differentiate each layer: \(\frac{du}{dx}=2\), \(\frac{dv}{du}=\cos u\), and \(\frac{dy}{dv}=-\sin v\).
Now multiply the rates in the chain: $$ \frac{dy}{dx} = (-\sin v)(\cos u)(2) = -2\sin(\sin(2x+1))\cos(2x+1). $$
Check at \(x=0\): The intermediate values are \(u=2(0)+1=1\) and \(v=\sin 1\). The outer rate is \(-\sin(\sin 1)\), the middle rate is \(\cos 1\), and the inner rate is \(2\). Their product is \(-2\sin(\sin 1)\cos 1\), which agrees with the derivative evaluated at \(0\).
Worked Example: Four Layers and a Simplification Check
Worked Example: Differentiate \(3\cos(2(x^2+1))+1\)
To make the layers explicit, define \(u=x^2+1\), \(v=2u\), \(w=\cos v\), and \(y=3w+1\). The layer derivatives are \(\frac{du}{dx}=2x\), \(\frac{dv}{du}=2\), \(\frac{dw}{dv}=-\sin v\), and \(\frac{dy}{dw}=3\).
Multiplying all four factors gives $$ \frac{dy}{dx} = \frac{dy}{dw}\frac{dw}{dv}\frac{dv}{du}\frac{du}{dx} = 3(-\sin v)(2)(2x) = -12x\sin(2(x^2+1)). $$
Check by grouping: First view the expression as \(3\cos(v)+1\), where \(v=2(x^2+1)\). The derivative with respect to \(v\) is \(-3\sin v\), and \(\frac{dv}{dx}=2(2x)=4x\). Multiplying gives \((-3\sin v)(4x)=-12x\sin(2(x^2+1))\), matching the four-layer calculation.
At \(x=1\), the intermediate values are \(u=2\), \(v=4\), \(w=\cos 4\), and \(y=3\cos 4+1\). The derivative factors are \(2\), \(2\), \(-\sin 4\), and \(3\), so their product is \(-12\sin 4\). Substitution of \(x=1\) into the result also gives \(-12\sin 4\).
Why the Repeated Rule Works
The chain rule says that if \(y=F(v)\) and \(v=G(x)\), then \(\frac{dy}{dx}=\frac{dy}{dv}\frac{dv}{dx}\), provided the functions are differentiable at the relevant values. A deeper composition can be treated as a sequence of these two-function compositions.
This argument extends to any finite number of differentiable layers. To see why, assume a composition of \(n\) layers has derivative equal to the product of its \(n\) local derivative factors. Add one more outer layer \(F\). The ordinary chain rule multiplies the existing derivative by \(F'\), evaluated at the output of the previous composition. The result therefore has \(n+1\) factors, one for each layer. Thus repeated application of the chain rule accounts for every layer, provided each component is differentiable at the value where it is used.
A Reliable Outside-In Routine
When a composition is complicated, a short written routine reduces errors. It is usually safer to name the intermediate functions first rather than trying to differentiate the entire expression mentally.
Ask what operation is applied last to the input expression. Its derivative is the first factor.
When differentiating the outer layer, evaluate its derivative at the complete input to that layer.
Differentiate that layer with respect to its own input, and multiply by the factor already found.
Stop only when the innermost expression has been differentiated with respect to \(x\).
There should be one derivative factor for every layer, each evaluated at the correct intermediate input.
Common Pitfall: Omitting an Inner Factor
A frequent error is to differentiate the outer layers correctly but forget to differentiate the expression inside them. For \(e^{\sin(x^2)}\), a common incorrect result is $$ e^{\sin(x^2)}\cos(x^2). $$ This includes the derivative of the exponential layer and the sine layer, but not the derivative of \(x^2\).
The correction is to include \(\frac{d}{dx}(x^2)=2x\): $$ \frac{d}{dx}e^{\sin(x^2)} = e^{\sin(x^2)}\cos(x^2)(2x). $$ For example, at \(x=1\), the incorrect expression gives \(e^{\sin 1}\cos 1\), while the correct derivative gives \(2e^{\sin 1}\cos 1\). The missing factor changes the value, so keeping a visible factor for every layer matters.
A related notation error is to write \(F'(x)\) for the derivative of the outer function in \(F(G(H(x)))\). The outer derivative must be evaluated at its input, \(G(H(x))\), so the correct factor is \(F'(G(H(x)))\). The inner expressions are not discarded when the outer function is differentiated.
Why This Method Matters
Deep compositions occur whenever several functions are applied in sequence. Repeated chain rule turns that nesting into a structured product of local rates. This is useful both for finding derivatives and for explaining where each factor comes from. It also gives a practical way to check work: compare the number of layers with the number of derivative factors, and inspect the input of each factor.
The method does not remove the need to check differentiability. The relevant component functions must be differentiable at the intermediate values reached by the composition. If a component is not differentiable there, the repeated chain-rule formula cannot simply be applied at that point. When those conditions hold, however, no new special rule is needed for additional layers: apply the chain rule again and retain every factor.
Check Your Understanding
For each question, identify the layers before differentiating. Keep the input to every derivative factor visible.
- Differentiate \(e^{\cos(x+2)}\), and state the three derivative factors.
- Write the repeated-chain-rule formula for \(F(G(H(x)))\) and identify the input to each derivative.
- Differentiate \(\sin(\cos(3x))\). How many layers are there?
- A student differentiates \(e^{\sin(x^2)}\) as \(e^{\sin(x^2)}\cos(x^2)\). Which layer’s derivative factor is missing?
- What differentiability condition is needed to apply the repeated chain rule at a given input?