Scalar chain rule
The derivative of a composition is the outer derivative evaluated at the inner output, times the inner derivative.
On this page 8 sections
- Overview
- A model often calculates an intermediate quantity and then uses it in another calculation
- For y=(x^2+1)^3, the outer cube has derivative 3u^2 at u=x^2+1
- A negative inner rate can reverse the final sign
- A prediction followed by a loss is a composition
- Key takeaway
- Sources & further reading
- Concept connections
01A model often calculates an intermediate quantity and then uses it in another calculation#
A model often calculates an intermediate quantity and then uses it in another calculation. The chain rule finds how a small input change travels through both stages. The final sensitivity depends on the rate of each stage, evaluated at the value that stage actually receives.
For , the inner output becomes the outer input. Multiply the outer rate at that intermediate value by the inner rate.
Let and . At , the intermediate value is . The outer derivative is , so its rate there is .
For at , write . The forward calculation gives . The inner rate is ; the square’s rate at is . Multiply to get . Using for the outer rate would evaluate the square at the wrong input.
Near , the inner output changes about units per unit of . Near , the outer output changes about units per unit of . The combined rate is .
The outer rate must be evaluated where the inner function actually lands.
. At , and . Also, and . Find at this input.
Show answer and explanation
Use the outer rate at , then multiply: .
02For y=(x^2+1)^3, the outer cube has derivative 3u^2 at u=x^2+1#
For , the outer cube has derivative at . The inner derivative is .
The outer factor alone is an incomplete derivative.
. Find .
Show answer and explanation
Outer rate: . Inner rate: . Multiply them.
03A negative inner rate can reverse the final sign#
A negative inner rate can reverse the final sign. For , the inner derivative is .
A zero inner rate makes the combined rate zero when the outer derivative exists at the intermediate value. Both stages must be differentiable at their respective inputs.
. At , and . Also, and . Claim: use . Repair .
Show answer and explanation
Use : .
04A prediction followed by a loss is a composition#
A prediction followed by a loss is a composition. The chain rule tells training software how a weight affects the loss through its effect on the prediction. Keeping the intermediate value and the local derivative separate is the habit used in backpropagation.
Evaluate the outer rate at the inner output, then multiply by the inner rate.
- Differentiate a composition of two scalar functions.
Sources & further reading
- [1]OpenStax Calculus Volume 1, 3.6: The chain rule ↗OpenStax Calculus Volume 1 · Book