📊Riemann Sum Calculator

Enter a function, interval [a, b], and number of subintervals to approximate the area under the curve. All four methods — left, right, midpoint, and trapezoidal — are computed simultaneously, with the selected method's rectangles drawn on the graph and step-by-step working shown below.

Quick examples
Left Sum —
Right Sum —
Midpoint Sum —
Trapezoidal —

Working

Enter a function above to see the working steps

Riemann Sum Calculator Online

Approximating the area under a curve? Our free Riemann sum calculator computes and visualises it the moment you enter your function. As a fast and reliable riemann sum calculator online, it takes any function over an interval [a, b] with your chosen number of subintervals and returns the left, right, midpoint, and trapezoidal approximations — so you can compare methods side by side.

But it does more than a number. It plots your function and overlays the rectangles or trapezoids used in the approximation, so you can actually see how the estimate is built and how it tightens as you increase n. A clear breakdown shows the width Δx, sample points, and summed area behind the result. Whether you're a student learning integration, checking homework, or teaching the concept, the maths and the picture are right in front of you.

Simply enter your function and interval to see the results instantly. No sign-up, no downloads, no limits — just clear calculus whenever you need it.

The Four Methods

Left Riemann Sum samples f at the left edge of each subinterval. It underestimates increasing functions and overestimates decreasing ones.

Right Riemann Sum samples f at the right edge. Its bias is the mirror image of the left sum on monotone functions.

Midpoint Riemann Sum samples f at the centre of each subinterval and is typically more accurate than left or right for the same n.

Trapezoidal Rule averages the left and right values, drawing trapezoids instead of rectangles. It gives the exact answer for any linear function and equals the average of the left and right sums.

Supported Functions

  • Polynomials: x^2, 3*x^3 - 2*x + 1
  • Trigonometric: sin(x), cos(x), tan(x)
  • Exponential & log: e^x, log(x), log(x, 10)
  • Roots: sqrt(x), x^(1/3)
  • Combinations: x * sin(x), e^(-x^2)

All calculations run entirely in your browser using math.js for safe function evaluation. No data is sent to a server. Results are numerical approximations — increase n to approach the true integral value.

About the Riemann Sum Calculator

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

Frequently Asked Questions

How does the Riemann sum calculator work?

Enter a function, the interval [a, b], and the number of subintervals n. The tool divides the interval into n equal parts of width Δx = (b−a)/n, evaluates the function at the appropriate sample points for the chosen method, and sums the rectangular (or trapezoidal) areas to approximate the area under the curve. The result is plotted with the shapes overlaid on the function graph.

Is this calculator free to use?

Yes, completely free with no sign-up, no downloads, and no limits. Run as many functions as you like.

What sum methods does it support?

It calculates left, right, midpoint, and trapezoidal Riemann sums simultaneously, so you can compare all four approximations for the same function and interval at a glance.

What is the difference between the methods?

The left and right sums use the function value at the left or right edge of each subinterval. The midpoint sum samples the function at the centre of each subinterval. The trapezoidal rule averages the left and right values, drawing trapezoids rather than rectangles. Midpoint and trapezoidal are typically more accurate than left or right sums for the same n, and the trapezoidal rule gives the exact answer for any linear function.

What functions can I enter?

You can enter standard math functions using the notation from math.js: polynomials (x^2, x^3 - 3*x), trigonometric (sin(x), cos(x), tan(x)), exponentials (e^x), logarithms (log(x)), square roots (sqrt(x)), and combinations (x * sin(x), e^(-x^2)).

Does it show the graph?

Yes. It plots the function curve and overlays the rectangles (for left, right, and midpoint methods) or trapezoids (for the trapezoidal rule) used in the approximation, so you can see exactly how the estimate is constructed. Changing the method updates the graph instantly.

What happens as I increase the number of subintervals?

The approximation generally converges toward the true definite integral. You can drag the slider or type a value for n and watch the rectangles narrow and the sum tighten in real time. For a monotone function, the left and right sums bracket the true value — as n → ∞, all four methods converge to the same limit.

Is my data stored anywhere?

No. Your function and inputs are processed entirely in your browser using math.js. Nothing is sent to a server, keeping your work completely private.

Does it work on mobile devices?

Yes. The tool is fully responsive — the graph scales to fill its container, and the layout stacks vertically on phones and tablets so inputs, graph, and results are all accessible without any horizontal scrolling.

How accurate is the result?

A Riemann sum is a numerical approximation, not the exact integral. Accuracy improves with more subintervals (larger n) and with the midpoint or trapezoidal method. The underlying arithmetic uses math.js floating-point evaluation, which is accurate to double precision for well-behaved functions.