Worked examples — Backpropagation — chain rule, gradient computation
The scenario matrix
Before working anything, let us list every distinct situation a backprop problem can be in. Each row is a "case class"; each worked example below is tagged with the cell it covers.
| # | Case class | What is special | Covered by |
|---|---|---|---|
| A | Linear output, positive slope | ReLU with , — the "clean" case | Ex 1 |
| B | Dead ReLU () | — the unit passes zero error backward | Ex 2 |
| C | Sigmoid, mid-range | is a fraction — error shrinks | Ex 3 |
| D | Saturated sigmoid | — the vanishing-gradient failure | Ex 4 |
| E | Fan-in node (weight feeds two paths) | must sum over paths (multivariable rule) | Ex 5 |
| F | Zero / degenerate input ( or ) | weight gradient collapses to | Ex 6 |
| G | Sign bookkeeping ( vs ) | error signal changes sign, so does every gradient | Ex 7 |
| H | Real-world word problem (aerospace surrogate) | translate physics → net → gradient | Ex 8 |
| I | Exam twist (shared weight / weight tying) | one weight used twice ⇒ gradients add | Ex 9 |
We will reuse this tiny network throughout unless stated otherwise:
Here is the input number, are weights (multipliers), are biases (offsets), is the activation function (the per-unit nonlinear bend), is the network's guess, is the true target, and is the loss (how wrong we are). The picture below is the map we walk backward on.

Ex 1 — Case A: linear/ReLU, positive slope (the clean baseline)
Forecast: Guess the sign of both gradients before reading. (Hint: will overshoot the target , so we expect positive gradients that push weights down.)
- Forward, cache everything. ; since , ; ; ; . Why this step? Backward slopes () and inputs () are read from these cached numbers — recomputing wastes work.
- Seed. . Why? .
- Layer 2. (output is linear, slope ). Then . Why? weight gradient = error out × signal in.
- Cross the nonlinearity. . Why? error flows back through (), then is scaled by the local slope .
- Layer 1. .
Verify: Bump by : , , so ✓. Both gradients positive as forecast — gradient descent will subtract them, lowering the weights toward a better fit.
Ex 2 — Case B: the Dead ReLU (error hits a wall)
Forecast: Will receive any gradient at all?
- Forward. . Since , . Why note this? ReLU has switched off — its output is stuck at .
- Local slope. because for the ReLU graph is flat. Why it matters: a flat function has zero derivative — nudging does nothing to .
- Backward. , hence . Why? The factor annihilates the error — no signal reaches .
Verify: Bump by : moves to (still ), so stays , stays , unchanged ✓.

Ex 3 — Case C: sigmoid mid-range (error shrinks by a fraction)
Forecast: At the sigmoid is at its steepest. What is that maximum slope?
- Forward. ; ; ; . Why? We need to evaluate the slope.
- Local slope. . Why this tool (product )? The sigmoid's derivative can be written using its own output, so once we cached we get the slope for free — a big reason sigmoids were popular.
- Seed & backward. ; ; then . Why? the incoming error is throttled to a quarter by the slope.
Verify: . Finite-difference around : bump , changes by ✓. Note never exceeds — every sigmoid layer shrinks the error by at least .
Ex 4 — Case D: saturated sigmoid (the vanishing gradient)
Forecast: Big means — is the slope big or tiny?
- Forward. . Why? We need the output to compute the slope.
- Slope. . Why this matters: the S-curve is flat far from the origin — the unit is saturated.
- Backward. Whatever error arrives, is crushed by a factor of . Why? Stack a few such layers and the product of tiny slopes — gradients vanish.
Verify: ✓. Contrast with Ex 3's : same function, weaker gradient just from a larger . This is exactly why ReLU replaced sigmoids in deep nets — see Vanishing Gradients.
Ex 5 — Case E: fan-in node (sum over paths)
Forecast: influences through two wires ( and ). Do we pick one or add them?
- Forward. ; ; ; ; .
- Seed & split. . Since : , . Why? , .
- Multivariable chain rule at the fan-in. reaches via and , so we sum the two path contributions: Why sum, not choose? Each path carries independent sensitivity; total sensitivity is their sum — this is the graph fan-in rule.
- To the input. .
Verify: Note , so , giving at ✓ — the closed form confirms the summed backprop.

Ex 6 — Case F: zero / degenerate input (gradient collapses)
Forecast: If the input is zero, does still learn?
- Forward. ; (ReLU, ); ; ; .
- Backward error at . ; .
- Weight vs bias gradient. Why the split? 's gradient is error × its input, and its input is — so gets no update. The bias's "input" is the constant , so it still learns.
Verify: Bump : is independent of , so never changes ✓. Bump by : rises by , by , so ✓.
Ex 7 — Case G: sign bookkeeping (undershoot vs overshoot)
Forecast: In Ex 1 the guess was too high; here it is too low. Which way flips?
- Forward. Identical to Ex 1: , , but now .
- Seed changes sign. . Why? The error signal is ; undershooting makes it negative.
- Propagate. ; . Why the flip? Gradient descent subtracts the gradient: a negative gradient means "increase " — exactly right, since is too small.
Verify: , the negation of Ex 1's ✓. Finite difference: bump by , , , slope ✓. Sign of the seed sets the sign of every downstream gradient.
Ex 8 — Case H: aerospace word problem (a lift surrogate)
Forecast: Is the model over- or under-predicting lift, and does go up or down?
- Forward. ; ReLU ; . Why? We must evaluate the prediction before we can measure error.
- Seed. (we underpredict lift).
- Cross ReLU. , so .
- Weight gradient. . Why? input into is .
- Update direction. Gradient descent: — the negative gradient raises , steepening the lift curve so climbs toward . ✓ physically sensible.
Verify: ; . Finite difference on : bump , , , slope ✓.
Ex 9 — Case I: exam twist (a weight used twice / weight tying)
Forecast: appears twice — is one term or a sum of two?
- Forward. ; ; .
- Seed. .
- Two uses ⇒ two paths. Treat each occurrence of as a distinct copy (in ) and (in ), then add their gradients (multivariable chain rule):
- via : .
- via : ; then . Why sum? A shared weight is a fan-in node in the graph — you sum the gradient contributed by each place it is used.
- Update. .
Verify: Closed form: , so ; ✓. Ignoring one occurrence would give — half the true gradient, the classic exam trap.
Recall
Connections
- Backpropagation (parent) — the machinery these examples exercise.
- Chain Rule — the engine behind every "sum over paths".
- Gradient Descent — consumes the gradients we computed to update weights.
- Vanishing Gradients — Cases B and D are its root causes.
- Activation Functions — ReLU vs sigmoid drove the slope factors above.
- Computational Graphs — fan-in nodes (Ex 5, Ex 9) are graph structure.
- Automatic Differentiation — automates exactly this bookkeeping.
- Neural Network Surrogate Models (CFD) — Ex 8's aerospace context.