Rung 23
Integration and the fundamental theorem
Accumulation, and its startling link back to slope.
Best attempted after 20. The derivative. Nothing stops you trying this now — the gate will tell you if you were right.
The gate
Compute the area under a curve two ways: numerically, by summing thin rectangles in code, and exactly, by finding an antiderivative. Show the numerical answer converging on the exact one as the rectangles get thinner, and state the rate at which the error falls.
Nobody checks this but you. Do it honestly and the rungs above hold; do it loosely and they will not, somewhere further up where the cause is much harder to find.
Two questions that look unrelated. How steep is this? — that was rung 20. How much has accumulated? — that is this one.
Slice the area under a curve into thin rectangles, add them up, make them thinner. The limit of that sum is the integral. It is rung 19's machinery again, pointed at a different question.
Then the surprise: the two questions are inverses. Differentiating undoes integrating. That is the fundamental theorem, and "fundamental" is not decoration — it is the reason integrals can be computed at all rather than merely approximated.
Why this is on the ladder
Because rung 38 defines probability over continuous outcomes as area under a curve, and there is no way to make sense of a probability density without this. Every expectation, every variance, every loss averaged over a distribution is an integral.
Do this
Take f(x) = x² from 0 to 1.
Numerically: divide the interval into n rectangles, evaluate the function at
each, multiply by the width, sum. Write it in Python — this is a rung 7 loop with
a rung 20 function inside it. Run it for n = 10, 100, 1000, 10000.
Exactly: find a function whose derivative is x². That is x³/3. Evaluate at the
endpoints and subtract: 1/3.
Watch your sums converge on 0.3333…. Then measure how fast — with rectangles
anchored on one side the error falls roughly in proportion to 1/n, so ten times
the work buys one more digit. That is a poor rate, and noticing it is what makes
better methods interesting later.
Where people get stuck
The constant of integration goes missing. Many functions have derivative x² —
they differ by a constant — and for a definite integral it cancels when you
subtract. Knowing why it cancels is different from not noticing it was there.
The other trap is believing the numerical sum because it looks stable. It agrees to a few digits and then stalls, for exactly the floating-point reason rung 20 uncovered. The exact answer is what tells you the sum is right, not the other way round.
Reading
- Integrals — Khan Academy
- 18.01SC Single Variable Calculus — MIT OpenCourseWare