Derivatives in Practice
Lab 1: Derivatives in Practice
You have seen the limit definition of the derivative and the rules for computing it analytically. This lab grounds those ideas in code: you will implement derivative approximations from first principles, verify the differentiation rules numerically, and use PyTorch's autograd to see what a framework actually computes under the hood.
What You'll Build
- A finite difference function that approximates using for decreasing values of , and a plot showing how accuracy improves then degrades with floating-point noise
- A rule verifier that checks the power rule, product rule, and chain rule by comparing your analytic derivative to the numerical estimate
- A tangent line visualizer that animates the secant line converging to the tangent as
- A sigmoid derivative explorer that plots and side-by-side, highlighting the vanishing gradient zones
- A PyTorch autograd checker that confirms all your analytic results match
.backward()to machine precision
Key Concepts Practiced
By the end you will understand why the limit definition is useful conceptually but numerical differentiation is impractical at scale; why autograd computes symbolic (not numerical) derivatives; and how the vanishing gradient problem appears directly from the sigmoid's derivative formula.