Instructional videos are coming to Albert.Join the waitlist
Tools
Practice
Tools

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

This free Riemann sum calculator finds left, right, midpoint and trapezoidal sums for any function on an interval, or for a table of values with unequal widths like the ones on AP® Calculus free-response questions, with a graph, the definite integral for comparison and every step.

Loading the riemann sum calculator…

How to use the Riemann sum calculator

  1. Choose the input. Pick Function f(x) to type a formula, or Table of values to enter x and f(x) values from a problem.
  2. Enter the function and interval (for example f(x) = x^2 from a = 0 to b = 2) and the number of subintervals n. For a table, list the x values in order and the matching f(x) values; the spacing can be uneven.
  3. Choose a method: left, right, midpoint or trapezoid.
  4. Read the result. You get the sum, the definite integral and the error (in function mode), a graph of the rectangles or trapezoids, a comparison of all four methods, a table of values and the steps. When f is increasing, decreasing or keeps one concavity, the calculator says whether the sum is an over- or underestimate.

Worked example

Water flows into a tank at a rate of R(t) gallons per hour. The table shows R(t) at selected times. Use a trapezoidal sum with the four subintervals in the table to approximate the total water that flows in from t = 0 to t = 12 hours.

t (hours) 0 2 5 9 12
R(t) (gallons per hour) 4.3 6.1 8.0 7.2 5.5
  1. Find each width. The subintervals are [0, 2], [2, 5], [5, 9] and [9, 12], with widths 2, 3, 4 and 3. They aren’t equal, so each trapezoid uses its own width.
  2. Find each area. A trapezoid’s area is width × average height:
    • 2 × (4.3 + 6.1) ÷ 2 = 10.4
    • 3 × (6.1 + 8.0) ÷ 2 = 21.15
    • 4 × (8.0 + 7.2) ÷ 2 = 30.4
    • 3 × (7.2 + 5.5) ÷ 2 = 19.05
  3. Add them. 10.4 + 21.15 + 30.4 + 19.05 = 81.

Interpretation: About 81 gallons of water flow into the tank from t = 0 to t = 12 hours. The units come from the rectangles or trapezoids: hours (width) × gallons per hour (height) = gallons. Choose Table of values, enter the two rows and pick Trapezoid rule to see the same four trapezoids.

What a Riemann sum approximates

The definite integral ∫ₐᵇ f(x) dx is the signed area between the graph of f and the x-axis from x = a to x = b. A Riemann sum approximates it by cutting [a, b] into subintervals, building a simple shape on each one, and adding the areas. When f is a rate, the same sum approximates the total amount of change, like gallons from gallons per hour or meters from meters per second.

Area below the x-axis counts as negative, so a Riemann sum can be negative or zero. The calculator shades those shapes in red.

The four methods

With n equal subintervals of width Δx = (b − a) ÷ n and points x₀ = a, x₁, …, xₙ = b:

Method Height of each shape Formula
Left Riemann sum f at the left endpoint Lₙ = Δx[f(x₀) + f(x₁) + … + f(xₙ₋₁)]
Right Riemann sum f at the right endpoint Rₙ = Δx[f(x₁) + f(x₂) + … + f(xₙ)]
Midpoint Riemann sum f at the middle of each subinterval Mₙ = Δx[f(m₁) + f(m₂) + … + f(mₙ)]
Trapezoidal sum Average of the two endpoint values Tₙ = (Δx ÷ 2)[f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ)]

For f(x) = x² on [0, 2] with n = 4, Δx = 0.5, and the four methods give:

Method Calculation Value
Left 0.5(0 + 0.25 + 1 + 2.25) 1.75
Right 0.5(0.25 + 1 + 2.25 + 4) 3.75
Midpoint 0.5(0.0625 + 0.5625 + 1.5625 + 3.0625) 2.625
Trapezoid 0.25(0 + 0.5 + 2 + 4.5 + 4) 2.75

The exact value is ∫₀² x² dx = 8/3 ≈ 2.6667. The trapezoidal sum is always the average of the left and right sums: (1.75 + 3.75) ÷ 2 = 2.75.

Overestimate or underestimate?

AP questions often ask whether an approximation is too big or too small, with a reason. The answer depends on how f behaves on the whole interval:

If f is… Left sum Right sum Midpoint sum Trapezoidal sum
Increasing Under Over – –
Decreasing Over Under – –
Concave up – – Under Over
Concave down – – Over Under

For a left sum on an increasing function, each rectangle’s height is the smallest value of f on its subinterval, so every rectangle sits below the curve. For a trapezoidal sum on a concave-up function, each trapezoid’s top edge is a chord that lies above the curve. If f changes direction or concavity inside the interval, there’s no general answer, and the calculator says nothing.

Tables with unequal widths

Free-response questions usually give a table rather than a formula, often with unequal spacing. The rule is simple: each subinterval uses its own width. You can’t factor out a single Δx, so write each term separately, as in the worked example.

A midpoint sum from a table needs the midpoint values in the table. With x = 0, 2, 4, 6, 8, “a midpoint sum with two subintervals” uses [0, 4] and [4, 8], with heights f(2) and f(6): 4·f(2) + 4·f(6). The calculator checks that each middle point really is halfway and tells you if it isn’t.

From sums to the definite integral

As the number of subintervals grows, every one of these sums approaches the same number, the definite integral:

∫ₐᵇ f(x) dx = lim (n → ∞) Σᵢ₌₁ⁿ f(xᵢ*) Δx

where xᵢ* is any point in the i-th subinterval. AP questions may give a sum in sigma notation, like Σᵢ₌₁ⁿ (2 + 3i/n)² · (3/n), and ask which integral it equals: here Δx = 3/n, the right endpoints are 2 + 3i/n, so the limit is ∫₂⁵ x² dx. Try increasing n in the calculator to watch the error shrink; for a smooth function, doubling n roughly halves the error of a left or right sum and quarters the error of a midpoint or trapezoidal sum.

Typing functions

Use x as the variable and type the formula the way you would on a graphing calculator. Powers use ^ (x^3, e^(-x)), and multiplication can be written with * or left out (3x, 2sin(x), x(x + 1)). Available functions are sin, cos, tan, sec, csc, cot, arcsin, arccos, arctan, ln, log (base 10), sqrt, abs and exp; |x − 1| works for absolute value, and pi stands for π. The interval ends can be expressions too, like pi/2. If part of a formula is undefined at a point the sum needs, such as ln(x) at x = 0, the calculator says which x is the problem.

Riemann sums on the AP® Calculus exam

Riemann sums are part of Unit 6, Integration and Accumulation of Change, on both AP® Calculus AB and BC, and table-based approximations appear on almost every free-response section. Show the setup with numbers (for example 2(4.3 + 6.1)/2 + …) before the total, and give units and meaning in context. For more practice, read Riemann Sums, Summation Notation, and Definite Integral Notation, How to Use the Trapezoid Rule and How to Do a Midpoint Riemann Sum, and browse the AP® Calculus AB cheat sheets and BC cheat sheets. After a practice test, estimate your score with the AP® Calculus AB Score Calculator or the AP® Calculus BC Score Calculator.

FAQ

How do you calculate a left Riemann sum?

Split [a, b] into n subintervals of width Δx = (b − a)/n. Evaluate f at the left end of each subinterval, add those heights, 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.

What is the trapezoidal rule formula?

With equal widths, T = (Δx/2)[f(x₀) + 2f(x₁) + 2f(x₂) + … + 2f(xₙ₋₁) + f(xₙ)]. Every inside value counts twice because it is a side of two trapezoids. The trapezoidal sum is also the average of the left and right sums.

How do I do a Riemann sum from a table with unequal widths?

Treat each subinterval separately: multiply its own width by its height (the left value, the right value, or the average of the two for a trapezoid), then add. For x = 0, 1, 3 and f = 2, 4, 10, the trapezoidal sum is 1 × (2 + 4)/2 + 2 × (4 + 10)/2 = 3 + 14 = 17. This is the format used in AP® Calculus free-response questions.

Is a Riemann sum an overestimate or an underestimate?

If f is increasing, a left sum underestimates and a right sum overestimates; if f is decreasing, it’s the reverse. If f is concave up, a trapezoidal sum overestimates and a midpoint sum underestimates; if f is concave down, it’s the reverse. The calculator states which applies when f keeps one behavior across the whole interval.

How do I type functions into the calculator?

Use x as the variable, ^ for powers and * or nothing for multiplication: 3x^2, 2sin(x), e^(-x), sqrt(x), ln(x), |x – 1| or abs(x – 1). Use pi for π. Functions include sin, cos, tan, sec, csc, cot, arcsin, arccos, arctan, ln, log (base 10), sqrt, abs and exp.

How accurate is the integral the calculator shows?

It’s found numerically with adaptive Simpson’s rule, accurate to many decimal places for smooth functions. It’s there so you can compare each sum with the true area. On the AP exam, use the Fundamental Theorem of Calculus or your calculator’s numerical integration (fnInt) for exact values.