Derivative Rules and the Chain Rule
Intuition
MA-10 estimates a derivative by nudging the input. Rules give the exact derivative of a formula built from simpler pieces. The most important is the chain rule: when one function feeds another, their rates of change multiply — the idea behind backpropagation.
Precise explanation
| Rule | Function | Derivative |
|---|---|---|
| power | ||
| sum | ||
| product | ||
| chain | ||
| exp, log | , | , |
| sigmoid |
In code, represent a differentiable function as a pair (f, df) of Python functions. Each
rule takes pairs and returns a new pair, so you can build derivatives of complicated formulas
from small, tested pieces.
def chain_rule(f, df, g, dg):
h = lambda x: f(g(x))
dh = lambda x: df(g(x)) * dg(x)
return h, dh
Worked example
: outer , inner with , so . At : and .
Common mistakes
- Forgetting the inner derivative: ; multiply by 3.
- Evaluating the outer derivative at instead of at .
- Product rule as .
Why this matters
Backpropagation (DL-10, DL-08) is the chain rule applied repeatedly, and gradient descent (MA-13) needs these derivatives.
References
- Mathematics for Machine Learning — Marc Peter Deisenroth, A. Aldo Faisal, Cheng Soon Ong (Cambridge University Press) (
S009) - CS231n: Backpropagation notes — Stanford University CS231n (
S016)