1.2.14 · D4Calculus & Optimization Basics

Exercises — Chain rule for multivariate functions (backprop foundation)

2,045 words9 min readBack to topic

Before we start, one picture to fix the vocabulary we reuse in every problem: a computational graph is just boxes (variables) joined by arrows (each arrow is one derivative). "Chain rule" = multiply the arrow-derivatives along a path, then add up all paths that reach the target.

Figure — Chain rule for multivariate functions (backprop foundation)

Level 1 — Recognition

Recall Solution 1.1

WHAT: We count paths from to . There are two: one through , one through . WHY: Each independent route contributes one product of arrow-derivatives; the chain rule sums them. Answer: 2 terms, each a product of two arrow-derivatives.

Recall Solution 1.2

is linear in each variable. The derivative w.r.t. a variable is just the coefficient sitting next to it. WHY: because are constants w.r.t. .

Recall Solution 1.3

No. It drops the second path through . Complete answer needs .


Level 2 — Application

Recall Solution 2.1

Step 1 — arrow-derivatives. Step 2 — sum the two paths ( and ). Step 3 — plug in : then .

Recall Solution 2.2

Only one path , so we just multiply. At : , so .

Recall Solution 2.3

WHY this identity matters: it lets backprop reuse the already-computed forward value instead of recomputing exponentials. At : , so (the maximum slope of the sigmoid).


Level 3 — Analysis

Figure — Chain rule for multivariate functions (backprop foundation)
Recall Solution 3.1

Chain rule (two paths , ): Substitute : Direct: . ✓ At : both give .

Recall Solution 3.2

Solve . Roots of : . Meaning: when the neuron is saturated (output near or near ), its arrow-derivative is nearly , so its contribution to every gradient is crushed — this is the seed of Vanishing and Exploding Gradients. See also Activation Functions for functions that dodge this. Answer: vanishes for or .

Recall Solution 3.3

WHAT it means: gradient descent updates . The gradient is negative, so is positive increases. (See Gradient Descent.)


Level 4 — Synthesis

Figure — Chain rule for multivariate functions (backprop foundation)
Recall Solution 4.1

Forward pass (left to right). Backward pass (right to left). Reuse each stored value. Now push into the hidden layer. , . WHY and share : both branch off the same node , whose upstream gradient is computed once and reused — that reuse is backprop on the computational graph.

Recall Solution 4.2

For linear maps the Jacobian is the matrix: , . By the vector chain rule, (see Jacobian and Hessian Matrices).


Level 5 — Mastery

Recall Solution 5.1

Step 1 — sum both output paths into : Step 2 — one more arrow to : . Step 3 — at : , so . This is the "fan-out then fan-in" pattern real graphs use everywhere — see Loss Functions for multi-term losses.

Recall Solution 5.2

(a) . (b) To first order, . Choosing gives . Since and , can only stay the same (if ) or decrease. That is the whole justification of Gradient Descent.

Recall Solution 5.3

Lesson: each layer shrinks the gradient by ; after 10 layers the signal reaching early weights is a millionth, so they barely learn. This is the vanishing-gradient problem, motivating ReLU-type Activation Functions whose slope is (no shrink).


Recall Self-check :::

One-path chain rule multiplies; multi-path chain rule ::: multiplies along each path, then adds the paths. Sigmoid's maximum slope occurs at ::: , giving . Backprop reuses each node's upstream gradient how many times? ::: Once, shared to all its children.