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.
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.
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 h | rise / run | error vs true slope |
|---|
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.
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.
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.