🌐 EN

∫ Riemann Sum Calculator (Definite Integral Approximation)

Enter a function f(x), interval [a, b], and number of subdivisions n, and this calculator approximates the definite integral using your chosen method — left, right, midpoint, or trapezoidal Riemann sum — while graphing the function and the approximating shapes.

Only basic arithmetic (+ − × ÷ ^) and sin, cos, tan, sqrt, pow, abs, exp, log, pi, e, x are allowed.

e.g. x^2, sin(x), sqrt(x)+1, pow(x,3)

Approximate Integral Value
Function Graph and Approximating Shapes
GUIDE

Learn more

01

What is a Riemann Sum?

A Riemann sum approximates the area (definite integral) between a function f(x) and the x-axis as the sum of many small rectangles (or trapezoids). The interval [a, b] is divided into n pieces of width Δx = (b−a)/n, and depending on how the height of each piece is chosen, you get the left Riemann sum, right Riemann sum, midpoint Riemann sum, or trapezoidal rule. As n grows (finer subdivisions), the approximation converges to the true definite integral.
02

Differences Between the 4 Methods

The left Riemann sum uses the function value at the left edge of each piece as the height, while the right Riemann sum uses the right edge. The midpoint Riemann sum uses the value at the midpoint of each piece, generally giving smaller error than left/right sums. The trapezoidal rule approximates with trapezoids instead of rectangles, often matching or beating the midpoint sum in accuracy. This calculator supports all 4 methods and draws the shapes matching your chosen method.
03

Expression Input and Safety

This calculator never uses eval() to run arbitrary code in your browser — it parses your input with a custom-built expression parser. Only numbers, x, the constants pi and e, basic arithmetic and exponentiation (^), parentheses, and the functions sin, cos, tan, sqrt, pow, abs, exp, log are allowed. Any other character or script syntax is rejected with an error before anything is evaluated.

Frequently asked questions

Which method is most accurate?
Generally, the midpoint Riemann sum and trapezoidal rule have smaller error than the left or right Riemann sums. Increasing the number of subdivisions (n) brings all four methods closer to the true definite integral.
What expressions can I enter?
Only basic arithmetic (+ − × ÷), exponentiation (^), the functions sin, cos, tan, sqrt, pow(a,b), abs, exp, log (natural log), the constants pi and e, and the variable x. Any other characters, function names, semicolons, etc. will show an error message.
Why is there a limit on the number of subdivisions (n)?
An excessively large n could take too long to compute and render in the browser, so it's capped at 10,000 for safety. Most approximations are already sufficiently accurate well within this range.