Lab 26

How fast, and how much

Calculus is two questions that turn out to be the same question backwards. Given a curve, how steep is it at each point? And given a curve, how much area is under it so far? Drag the point below and watch the first answer draw itself. Then stack the rectangles and watch the second one come back round to where you started.

Curve

1The slope at a point

Drag Point. The straight line touching the curve is the tangent, and its steepness is the derivative there. Every slope you visit gets plotted in the strip underneath β€” so by dragging from one end to the other you draw the derivative curve yourself. Turn Sweep on to let it run.

The slope, plotted as you go

2Why it needs a limit

You cannot measure a slope at a single point β€” a point has no width. So take two points a gap h apart, measure the slope between them, then shrink h. Drag Gap used for the slope down and watch the chord swing onto the tangent. The table is the answer at each size of gap: it settles, and the value it settles on is the derivative. Try it on sin x first and then on xΒ² β€” one of those is exact at every gap, and it is worth working out why.

gap hrise / runerror vs true slope

3The area underneath

Now the other question. Chop the region under the curve into rectangles and add them up. With 3 rectangles the answer is poor; with 200 it is very close. Area below the axis counts as negative, which is why the total can go down as you sweep right. Watch the error column fall as you add rectangles β€” and note it falls in a very particular way.

4And the two are the same question

The line below is the running total of area, from the left edge up to each point. Now look at its steepness: where the original curve is high, the area is climbing fast; where the original dips below the axis, the area falls. The slope of the area curve is the original curve. That is the fundamental theorem of calculus, and it is why differentiation and integration undo each other.

What this page is actually computing

Everything here is numerical, not symbolic. The slope is a central difference β€” (f(x+h) βˆ’ f(xβˆ’h)) / 2h β€” and the area is a Riemann sum of the rectangles you can see. No algebra is being done anywhere: the page does not know that the derivative of xΒ² is 2x, it just measures the curve in front of it. That is exactly how a physics engine, a graphics renderer or a neural network trainer does it too.

It also inherits the drawback. Shrink the gap far enough and the answer gets worse, not better: subtracting two nearly equal numbers throws away most of the digits a computer is holding. On sin x or e^(x/2) the error in step 2 falls to about 10⁻¹¹ around h = 10⁻⁡ and then climbs again β€” there is a best gap, and it is nowhere near as small as you would guess. Symbolic calculus has no such floor, which is the honest argument for learning the algebra as well.

One curve here escapes that entirely. For xΒ² the chord between xβˆ’h and x+h has exactly the slope of the tangent whatever h you pick, because the errors on the two sides are equal and cancel. Its error column starts at zero and only ever gets worse. Worth switching between the curves to see it.

Reference

The four ideas