CALCULUS / 3. DIFFERENTIATION RULES
Differentiation Rules
Sum, product, quotient, chain — the toolkit for any function
EXPLANATION
You rarely compute derivatives from the limit definition. Instead you use rules that combine simpler derivatives. From Table 2 of Raschka's calculus appendix: Sum rule: d/dx[f+g] = f' + g' Difference rule: d/dx[f-g] = f' - g' Product rule: d/dx[f·g] = f'·g + f·g' Quotient rule: d/dx[f/g] = [g·f' - f·g'] / g² Chain rule: d/dx[f(g(x))] = f'(g(x)) · g'(x) Power rule: d/dx[xⁿ] = n·xⁿ⁻¹ Constant rule: d/dx[c] = 0 The chain rule is the most important for deep learning — it's what makes backpropagation work. Every layer in a neural network is a composition of functions, and the chain rule tells you how to differentiate through them. In Leibniz notation, the chain rule looks like fractions canceling: df/dx = (df/dg) · (dg/dx) The dg "cancels" — this makes it easy to remember and apply to long chains of composed functions.
DIAGRAM
Chain rule example: f(x) = log(√x)
Decompose: g(x) = √x, f(g) = log(g)
Step 1: derivative of outer w.r.t. inner
df/dg = d/dg[log(g)] = 1/g = 1/√x
Step 2: derivative of inner w.r.t. x
dg/dx = d/dx[x^(1/2)] = (1/2)x^(-1/2) = 1/(2√x)
Step 3: multiply
df/dx = (1/√x) · (1/(2√x)) = 1/(2x)
Neural network chain:
Loss = L(ŷ), ŷ = f(z), z = Wx + b
dL/dW = (dL/dŷ) · (dŷ/dz) · (dz/dW)
Each term computed by backprop, layer by layerCODE