Enter a function, an interval [a, b] and the number of subintervals n to approximate the area under the curve. See the left, right, midpoint or trapezoid rectangles drawn on the graph, the full table of sample points, the working, and how close each method gets to the true integral.
Last updated:
Examples:
Use x as the variable: ^, sqrt, ln, log, e^x, sin, cos, tan, abs, pi; 2x and 3sin(x) work too. a and b can be expressions like pi/2. Angles are in radians.
Left Riemann sum L₄1.75
f(x)Positive areaNegative area
Step-by-step
Table of values
How the sum converges as n grows
Advertisement
Advertisement
How to use the Riemann Sum Calculator
Type the function f(x), for example x^2, sin(x) or e^(-x^2).
Enter the interval a and b (expressions like pi are allowed) and the number of subintervals n.
Choose the method: Left, Right, Midpoint or Trapezoid. The sum and graph update instantly.
Drag the n slider to watch the rectangles fill the area and the error shrink.
Read the steps and table, compare the methods, and download the table as CSV if you need it.
Riemann sum formulas
With Δx = (b − a)/n and grid points xi = a + i·Δx for i = 0, 1, …, n:
Method
Formula
Error behaviour (smooth f)
Left sum Lₙ
Δx·[f(x₀) + f(x₁) + … + f(xₙ₋₁)]
Proportional to 1/n
Right sum Rₙ
Δx·[f(x₁) + f(x₂) + … + f(xₙ)]
Proportional to 1/n
Midpoint sum Mₙ
Δx·[f(m₁) + … + f(mₙ)], mᵢ = (xᵢ₋₁ + xᵢ)/2
Proportional to 1/n²
Trapezoidal Tₙ
(Δx/2)·[f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ)]
Proportional to 1/n², about twice the midpoint error
The exact value is 8/3 ≈ 2.6667, so the midpoint sum is closest, the trapezoid is slightly over, and the left and right sums miss by a full 0.92 and 1.08.
Over- or underestimate?
Increasing f: left sum is too small, right sum is too big. Decreasing f: the reverse.
Concave up f (like x²): the trapezoid overestimates and the midpoint underestimates. Concave down: the reverse.
The exact integral always lies between the left and right sums when f is monotonic on [a, b], and between Mₙ and Tₙ when f keeps the same concavity.
Remember that AP-style notation LRAM, RRAM and MRAM mean the same as left, right and midpoint sums.
Frequently asked questions
What is a Riemann sum?
A Riemann sum approximates the area under a curve, the definite integral of f from a to b, by splitting [a, b] into n subintervals of width Δx = (b − a)/n and adding up the areas of rectangles. Each rectangle's height is the function value at a chosen sample point in its subinterval.
What is the difference between left, right and midpoint sums?
They use different sample points. A left sum uses the left endpoint of each subinterval, x₀ to xₙ₋₁; a right sum uses the right endpoint, x₁ to xₙ; a midpoint sum uses the centre of each subinterval. For an increasing function the left sum underestimates and the right sum overestimates the area.
How do you calculate a left Riemann sum by hand?
Compute Δx = (b − a)/n, list the left endpoints a, a + Δx, …, a + (n − 1)Δx, evaluate f at each one, add the values and multiply by Δx. For f(x) = x² on [0, 2] with n = 4: Δx = 0.5 and L₄ = 0.5·(0 + 0.25 + 1 + 2.25) = 1.75.
How is the trapezoidal rule related to Riemann sums?
The trapezoidal sum is the average of the left and right sums: T = (L + R)/2. It joins neighbouring points with straight lines instead of flat tops, so T = (Δx/2)[f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ)].
Which method is most accurate?
For smooth functions the midpoint and trapezoidal sums are much more accurate than left or right sums: their error falls roughly by a factor of 4 each time n doubles, versus a factor of 2. Simpson's rule, a weighted combination of the two, is more accurate still. The convergence table shows these ratios for your function.
What happens when the function is below the x-axis?
Rectangles below the axis have negative height, so they subtract from the sum. A Riemann sum therefore approximates the signed (net) area. The graph shades negative parts in orange; to get total area, split the interval where f changes sign and add the absolute values.
Why does the sum approach the integral as n grows?
As n increases the rectangles get narrower, so they follow the curve more closely and the gaps or overlaps shrink. The definite integral is defined as the limit of Riemann sums as n → ∞ (for any choice of sample points), provided the function is integrable.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.