CALCULUS / 7. MULTIVARIABLE CHAIN RULE
Multivariable Chain Rule & Jacobian
Gradients for vector functions — the full generalization
EXPLANATION
The multivariable chain rule extends the chain rule to functions with multiple inputs and outputs. For f(g(x), h(x)) — one output, two intermediate functions: df/dx = (∂f/∂g)(dg/dx) + (∂f/∂h)(dh/dx) In vector form (from Raschka's appendix): df/dx = ∇f · v'(x) where v = [g(x), h(x)]ᵀ The Jacobian matrix: when f: Rⁿ → Rᵐ (vector input, vector output): J[i,j] = ∂fᵢ/∂xⱼ The Jacobian is an m×n matrix containing all first-order partial derivatives. For a single function f: Rⁿ → R (like a loss function): • Gradient ∇f is a column vector (n×1) • Jacobian Jf is a row vector (1×n) = ∇f ᵀ In deep learning, the Jacobian of a layer's output w.r.t. its input describes how that layer transforms gradients during backprop. For a linear layer z = Wx + b, the Jacobian w.r.t. x is simply W.
DIAGRAM
Multivariable chain rule example:
f(g,h) = g²h + h, g(x)=3x, h(x)=x²
∂f/∂g = 2gh
∂f/∂h = g² + 1
dg/dx = 3
dh/dx = 2x
df/dx = (∂f/∂g)(dg/dx) + (∂f/∂h)(dh/dx)
= 2gh·3 + (g²+1)·2x
= 6gh + 2x(g²+1)
Jacobian of f: R² → R²
f₁(x,y) = x² + y
f₂(x,y) = xy
∂f₁/∂x ∂f₁/∂y 2x 1
J = [ ] = [ ]
∂f₂/∂x ∂f₂/∂y y xCODE