Interactive
How close can rectangles get?
The area under f(x) = x² + 1 from 0 to 3 is exactly 12. Drag the slider and watch the rectangles close the gap — then switch where you measure each height and watch the answer jump to the other side.
Try it below Join free — an occasional piece worth your time
8 rectangles, midpoint: 11.9648 — the true area is 12, so this is 0.0352 under.
Every rectangle has the same width. The approximation is only as good as the number of rectangles — and the sign of the error depends on which end you measure from.
What you are looking at
Cut the interval [0, 3] into n equal pieces, build a rectangle on each piece with its height taken from the curve, and add the areas. That sum is a Riemann sum. It is an approximation, and the point of the topic — the reason it opens the integral in AP Calculus AB and BC — is that the approximation gets better in a controlled way as n grows, and that the limit is the integral.
Two things are worth noticing while you drag. First, the error shrinks roughly like 1/n for left or right endpoints but like 1/n² for midpoints, so the midpoint sum is much closer for the same work. Second, for a function that is increasing the whole way, every left sum is too small and every right sum is too large: the true area is squeezed between them. That squeeze is the argument behind the definite integral, and it is the one students can check for themselves here.
Further reading: OpenStax Calculus Volume 1 §5.1, Approximating Areas — checked 1 Nov 2026.
Second playground
The derivative is a slope you can lean on
Same curve, different question: how steep is f(x) = x² at one point? Drag the point, then shrink the step h and watch the secant line settle onto the tangent.
At a = 0.6 the curve is at 0.36 and the tangent slope is 1.20. Measured over a step of h = 0.5, the secant slope is 1.70 — exactly 0.5 too steep.
The secant slope over a step h is always the tangent slope plus h itself, which is why the gap closes exactly when h does. That limit is the derivative.
Third playground
How a machine rolls downhill
Gradient descent is the loop that trains most machine-learning models: read the slope, take a step downhill, repeat. Here is the whole idea on one curve, f(x) = x⁴/4 − x² + x/2 — pick a starting point and a step size, and watch where it ends up.
Start at 1.9 with a step of 0.20: after 11 steps it settles at x = 1.2670, where f = −0.3276. The deepest point on this curve is −1.7360 at x = −1.5257 — this run never saw it.
Each step is the slope times the step size: big strides on a steep hillside, a crawl on a flat floor. A step too big and it overshoots; too small and it takes all day. And notice which valley it lands in — gradient descent finds a minimum, not the lowest one.