Riemann Sum & Integration as Area

Slice the area under a curve into rectangles. As you add more slices, the sum closes in on the true integral.

Function:
n 8
a 0
b 2
Riemann sum (Σ)
Exact integral (∫)
Error |Σ − ∫|
What you're seeing. Each rectangle's area is f(sample) · Δx, where the sample point sits at the rectangle's left edge, right edge, or middle (your choice above). Add them up and you get a Riemann sum — an approximation of the area under the curve between a and b. The smaller the slices (larger n), the closer the sum gets to the true integral.

When the curve dips below the x-axis, the rectangles flip red and count as negative area. So the sum is really a signed area, not just "how much is under the curve". Try the x3 − 3x function over [-2, 2] to see this: the positive and negative halves cancel exactly.