About the Riemann Sum Calculator
What it does, how the four methods compare, and how to read the results.
What is a Riemann sum?
A Riemann sum is a method for approximating the definite integral of a function โ in other words, the area between the function curve and the x-axis over an interval [a, b]. The interval is divided into n subintervals of equal width ฮx = (bโa)/n, and the area of a rectangle (or trapezoid) is computed for each subinterval. Summing these areas gives the approximation. As n increases, the rectangles narrow and the sum converges to the true integral.
The concept was formalised by Bernhard Riemann in the 19th century and forms the foundation of the rigorous definition of the definite integral taught in calculus courses worldwide.
The four methods
Left Riemann Sum
Samples f at the left endpoint of each subinterval: xโ, xโ, โฆ, xโโโ. Underestimates increasing functions, overestimates decreasing ones. Easy to compute by hand for small n.
Right Riemann Sum
Samples f at the right endpoint: xโ, xโ, โฆ, xโ. The bias is opposite to the left sum for monotone functions. Together, left and right sums bracket the true integral for monotone f.
Midpoint Riemann Sum
Samples f at the midpoint of each subinterval: xโ + ฮx/2, xโ + ฮx/2, โฆ. Typically more accurate than left or right sums for the same n and is a second-order method.
Trapezoidal Rule
Averages the left and right endpoint values for each subinterval, drawing trapezoids rather than rectangles. Exact for linear functions, and equal to the average of the left and right Riemann sums.
What the calculator does
The Riemann sum calculator takes a function string (e.g. x^2, sin(x)), compiles it using math.js, and evaluates it at the required sample points. All four sums are computed simultaneously so you can compare them without re-entering anything. The selected method's rectangles or trapezoids are drawn on a Chart.js graph overlaid on the function curve.
A step-by-step working section shows ฮx, each individual term, and the running total โ so you can follow the arithmetic by hand or use it as a teaching aid.
All computation runs in your browser โ no data is sent to any server and nothing is stored between sessions.
When to use each method
Left or Right sum: use when you need a quick check or are following a textbook exercise that specifies a particular endpoint. Note the direction of the error (under or overestimate) depends on whether f is increasing or decreasing.
Midpoint sum: use for the best accuracy from the four simple methods when you cannot use Simpson's rule. It is a second-order method, meaning halving n reduces the error by a factor of four.
Trapezoidal rule: use when the function is nearly linear in each subinterval, or when you already have tabulated values at the endpoints of each subinterval. It is exact for polynomials of degree โค 1.
For the highest accuracy, increase n until successive approximations agree to the required number of decimal places, or use the midpoint or trapezoidal methods which converge faster than left or right sums.
Supported functions
Polynomials
x^2, 3*x^3 - 2*x + 1, x^0.5
Trigonometric
sin(x), cos(x), tan(x), atan(x)
Exponential & log
e^x, log(x), log(x, 10), 2^x
Roots
sqrt(x), x^(1/3), cbrt(x)
Combinations
x * sin(x), e^(-x^2), log(x) / x
Constants
pi, e, tau โ all recognised automatically
Try the Riemann Sum Calculator
Compare all four methods instantly โ no sign-up required.
Open the Calculator โ