Riemann Sum Calculator (Left, Right, Midpoint, Trapezoid)

Left, right, midpoint and trapezoid sums for a polynomial on [a, b] with n intervals, each compared with the exact integral and its error.

1, 0, 0 means x². Use 0 for a missing power. Up to degree 20. Use a point for decimals (1.5), no thousands separators, and separate numbers with spaces or a comma and a space.
Must be greater than a.
A whole number from 1 to 100,000.
All four sums are shown; this one is the main answer.

Results

Left endpoint sum Lₙ
1.75
Exact integral
2.6667
Exactly 8/3.
Error of the left sum (sum − exact)
-0.916667
Left endpoint sum Lₙ
1.75
Right endpoint sum Rₙ
3.75
Midpoint sum Mₙ
2.625
Trapezoidal rule Tₙ
2.75
Width of each subinterval Δx = (b − a)/n
0.5
All four compared with the exact value
Left endpoint sum Lₙ = 1.75 error −0.9166666667 (34.38%) Right endpoint sum Rₙ = 3.75 error 1.083333333 (40.62%) Midpoint sum Mₙ = 2.625 error −0.04166666667 (1.563%) Trapezoidal rule Tₙ = 2.75 error 0.08333333333 (3.125%)
Function values used
i | xᵢ₋₁ to xᵢ | f(left) | f(midpoint) | f(right) 1 | 0 to 0.5 | 0 | 0.0625 | 0.25 2 | 0.5 to 1 | 0.25 | 0.5625 | 1 3 | 1 to 1.5 | 1 | 1.5625 | 2.25 4 | 1.5 to 2 | 2.25 | 3.0625 | 4
Function
f(x) = x² on [0, 2], n = 4

How it’s calculated

A Riemann sum estimates the area under a curve by splitting [a, b] into n equal subintervals of width Δx = (b − a)/n and adding up rectangles. The height of each rectangle is f at the left end, the right end or the middle of its subinterval. The trapezoidal rule joins the endpoints with straight lines instead, and equals the average of the left and right sums.

Lₙ = Δx × [f(x₀) + f(x₁) + … + f(xₙ₋₁)] Rₙ = Δx × [f(x₁) + f(x₂) + … + f(xₙ)] Mₙ = Δx × [f(m₁) + f(m₂) + … + f(mₙ)] mᵢ = midpoint of subinterval i Tₙ = Δx/2 × [f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ)]

Because f is a polynomial, the exact integral is also known (from its antiderivative), so the calculator shows how far off each estimate is. All four approach the exact value as n grows. The midpoint and trapezoid errors shrink roughly with 1/n², the left and right errors only with 1/n.

Example: f(x) = x² on [0, 2] with n = 4, so Δx = 0.5 and x = 0, 0.5, 1, 1.5, 2. L₄ = 0.5 × (0 + 0.25 + 1 + 2.25) = 1.75; R₄ = 0.5 × (0.25 + 1 + 2.25 + 4) = 3.75; M₄ = 0.5 × (0.0625 + 0.5625 + 1.5625 + 3.0625) = 2.625; T₄ = (1.75 + 3.75)/2 = 2.75. The exact value is 8/3 ≈ 2.6667, so the left sum underestimates (x² is increasing) and the right sum overestimates.

If you only have measured data points rather than a formula, use the numerical integration calculator instead.

Frequently asked questions

Which Riemann sum is most accurate?

Usually the midpoint sum, then the trapezoidal rule; both have errors that shrink with 1/n². The left and right sums are less accurate, with errors shrinking with 1/n.

When does the left sum underestimate?

When f is increasing on the interval, every left-endpoint rectangle sits below the curve, so Lₙ is too small and Rₙ too big. For a decreasing function it is the other way round.

Why is the trapezoid sum the average of left and right?

Each trapezoid has area Δx × (f(xᵢ₋₁) + f(xᵢ))/2, which is the average of the left and right rectangles on that subinterval.

How large can n be?

Up to 100,000. The table lists the first 20 subintervals.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator