Chain Rule

Calculus & Advanced Math

The chain rule differentiates composite functions by multiplying the derivative of the outer function by the derivative of the inner function.

Formula

\frac{d}{dx}[f(g(x))] = f'(g(x)) \cdot g'(x)

Definition

The chain rule handles functions inside other functions. Differentiate the outside function first (leaving the inside alone), then multiply by the derivative of the inside.

Example

$d/dx[\sin(x^2)]$: the outside is $\sin(\ )$, so $\cos(x^2)$, times the derivative of $x^2$, which is $2x$. Answer: $2x\cos(x^2)$.

Key Insight

Think of it as a chain: the outer layer changes, so you must also account for how fast the inner layer is changing.

Definition

If $y = f(u)$ and $u = g(x)$, then $dy/dx = (dy/du)(du/dx) = f'(g(x)) \cdot g'(x)$. This "cancellation" of $du$ in Leibniz notation makes the chain rule intuitive to apply.

Example

$f(x) = (3x^2 + 1)^5$: let $u = 3x^2 + 1$. Then $dy/dx = 5u^4 \cdot 6x = 30x(3x^2 + 1)^4$.

Key Insight

Almost every non-trivial derivative requires the chain rule. Recognizing the "inside" and "outside" functions is the key skill.

Definition

For $f: \mathbb{R}^m \to \mathbb{R}^k$ and $g: \mathbb{R}^n \to \mathbb{R}^m$, the chain rule states $D(f \circ g)(x) = Df(g(x)) \cdot Dg(x)$, where $D$ denotes the Jacobian matrix. This reduces to the scalar rule when $m = n = k = 1$.

Example

Backpropagation in neural networks is a direct application of the multivariable chain rule, computing gradients layer by layer from output to input.

Key Insight

The chain rule is the computational heart of automatic differentiation and reverse-mode autodiff (used in deep learning), making it one of the most practically powerful theorems in applied mathematics.