Compute left, right and midpoint Riemann sums for a function over an interval.
Riemann sums approximate ∫f(x)dx by dividing [a,b] into n equal rectangles. The left sum uses left endpoints, right sum uses right endpoints, and midpoint sum uses the center of each subinterval. The midpoint rule is generally more accurate (O(h²)) than left or right sums (O(h)).
Left Riemann sum
L = Σ f(xᵢ)·Δx for i = 0 to n-1
Midpoint rule
M = Σ f((xᵢ + xᵢ₊₁)/2)·Δx
The midpoint sum is generally the most accurate, with error O(h²). Left and right sums have O(h) error but bound the integral from above/below for monotone functions.
The definite integral is defined as the limit of Riemann sums as n → ∞. Larger n gives better approximations.