Riemann Sum Calculator

Left, right, midpoint and trapezoidal sums with rectangles drawn under f(x).

  1. Enter valuesUse your own inputs or an example
  2. CalculateApply your selected settings
  3. View resultExplore the answer and explanation

Enter the function and interval

Enter your values below to get started.

Examples:
f(x) =
Use x as the variable: x^2, sin(x), e^x, 1/x, sqrt(x).
Method
Reset restores the default values.

Tips for this calculator

Write powers with ^: x^3, 2^x.

Bounds accept pi, e and fractions like 1/2.

Pick Compare all to see the 4 methods side by side.

Double n and watch the error shrink about 2× (left, right) or 4× (midpoint, trapezoid).

A Riemann sum calculator estimates the area under a curve f(x) on an interval [a, b] by adding n rectangles. Enter the function, the bounds and the number of subintervals to get the left, right, midpoint or trapezoidal sum, every rectangle in a table, and a graph that shows the error against the exact integral.

What is a Riemann Sum?

A Riemann sum is an approximation of the area under a curve, built by adding the areas of n thin rectangles. Each rectangle has width Δx and a height equal to f(x) at one sample point inside its subinterval.

∑i=1nf(xi∗) Δx,Δx=b−an\sum_{i=1}^{n} f(x_i^{*})\,\Delta x, \qquad \Delta x = \frac{b-a}{n}

German mathematician Bernhard Riemann (1826–1866) formalized the idea in 1854. When n grows without bound, the sum approaches the definite integral ∫ab f(x) dx, which is why Riemann sums are the bridge between sums and integrals in calculus.

For f(x) = x² on [0, 2], 4 left rectangles give an area of 1.75, while the exact area is 8/3 ≈ 2.6667. With 100 rectangles, the left sum is 2.6268, an error of 1.5%.

InteractiveAdd rectangles and watch the area converge

How Does the Riemann Sum Calculator Work?

The calculator splits [a, b] into n equal subintervals, evaluates f(x) at the chosen sample point of each one, multiplies by Δx and adds the results. It then compares the sum with the exact integral, computed with Simpson's rule on 2,000 subintervals.

InteractivePartition the interval: Δx and sample points
  1. Find Δx

    Δx = (b − a) / n. For [0, 2] and n = 4, Δx = 0.5.

  2. Place sample points

    Left uses xi−1, right uses xi, midpoint uses (xi−1 + xi) / 2.

  3. Evaluate f(x)

    Each height f(xi*) is computed and listed in the table tab.

  4. Add the areas

    The sum of f(xi*) · Δx is the Riemann sum; the error is the gap to the integral.

Riemann Sum Formula

The general Riemann sum formula is S = Σ f(xi*) Δx, summed from i = 1 to n. The 4 standard rules differ only in where xi* sits.

Left Riemann Sum Formula

Ln=Δx∑i=0n−1f(a+i Δx)L_n = \Delta x \sum_{i=0}^{n-1} f(a + i\,\Delta x)

Right Riemann Sum Formula

Rn=Δx∑i=1nf(a+i Δx)R_n = \Delta x \sum_{i=1}^{n} f(a + i\,\Delta x)

Midpoint Riemann Sum Formula

Mn=Δx∑i=1nf ⁣(a+(i−12)Δx)M_n = \Delta x \sum_{i=1}^{n} f\!\left(a + \left(i - \tfrac{1}{2}\right)\Delta x\right)

Trapezoidal Rule Formula

Tn=Δx2[f(x0)+2f(x1)+⋯+2f(xn−1)+f(xn)]=Ln+Rn2T_n = \frac{\Delta x}{2}\left[f(x_0) + 2f(x_1) + \cdots + 2f(x_{n-1}) + f(x_n)\right] = \frac{L_n + R_n}{2}
InteractiveCompare the 4 formulas on one function

Types of Riemann Sums

There are 6 common types of Riemann sums: left, right, midpoint, trapezoidal, upper and lower. On an increasing function, the left sum underestimates and the right sum overestimates; on a decreasing function, the roles swap.

InteractiveOver or under? Flip the curve and the method

Left Riemann Sum

Height from the left endpoint of each subinterval. Underestimates increasing functions.

Right Riemann Sum

Height from the right endpoint. Overestimates increasing functions.

Midpoint Riemann Sum

Height from the center. Error shrinks with 1/n², about half the trapezoidal error.

Trapezoidal Sum

Average of left and right sums; uses trapezoids instead of rectangles.

Upper Riemann Sum

Height is the maximum of f on each subinterval, so it is always ≥ the integral.

Lower Riemann Sum

Height is the minimum of f on each subinterval, so it is always ≤ the integral.

How to Calculate a Riemann Sum by Hand

To calculate a Riemann sum by hand, find Δx, list the sample points, evaluate f at each point, add the values and multiply by Δx. Here is the right sum of f(x) = x² on [0, 2] with n = 4.

  1. Δx = (2 − 0) / 4 = 0.5.
  2. Right endpoints: 0.5, 1, 1.5, 2.
  3. Heights: 0.25, 1, 2.25, 4.
  4. Sum of heights: 7.5.
  5. R4 = 0.5 × 7.5 = 3.75.
InteractiveStep through a Riemann sum by hand

    Riemann Sums and the Definite Integral

    A function is Riemann integrable when every Riemann sum approaches the same limit as the widest subinterval shrinks to 0. That limit is the definite integral.

    ∫abf(x) dx=lim⁡n→∞∑i=1nf(xi∗) Δx\int_a^b f(x)\,dx = \lim_{n\to\infty} \sum_{i=1}^{n} f(x_i^{*})\,\Delta x

    Every continuous function on a closed interval is Riemann integrable, as is any bounded function with finitely many jumps. The error of the left and right sums shrinks in proportion to 1/n; the midpoint and trapezoidal errors shrink in proportion to 1/n², so 10× more rectangles give 100× less error.

    InteractiveError vs. number of rectangles

    Common Mistakes with Riemann Sums

    • Using n instead of Δx: the sum of heights must be multiplied by Δx = (b − a)/n.
    • Off-by-one endpoints: left sums run from x0 to xn−1; right sums from x1 to xn.
    • Mixing degrees and radians: trigonometric functions use radians, so π ≈ 3.1416, not 180.
    • Treating negative area as positive: parts of f below the x-axis subtract from the sum.
    • Assuming midpoint = trapezoid: they are different rules with errors of opposite sign on convex curves.
    InteractiveTrue or false: Riemann sums
    1. For an increasing function, the left Riemann sum overestimates the area.

    2. The trapezoidal sum equals the average of the left and right sums.

    3. Doubling n cuts the midpoint error by about 4×.

    4. Area below the x-axis adds a positive amount to a Riemann sum.

    5. Δx = (b − a) / n for a regular partition.

    Score: 0 / 5

    How to Use the Riemann Sum Calculator

    Type f(x), set a, b and n, pick a method and press Calculate. The result card shows the sum, Δx, the exact integral and the error; the tabs show the steps, every rectangle and the graph.

    InteractiveLoad a ready-made problem

    Each button fills the calculator and runs it.

    1. Enter f(x)

      Type the function with x as the variable, for example x^3 - 2x.

    2. Set a, b and n

      Enter the limits of integration and the number of subintervals (1 to 10,000).

    3. Choose a method

      Left, right, midpoint, trapezoidal, or Compare all.

    4. Read the graph

      Open the Chart tab to see each rectangle against the curve.

    Real-Life Applications of Riemann Sums

    Riemann sums turn a rate measured at intervals into a total. Common uses:

    • Distance from speed: speed readings every 10 seconds add up to distance traveled.
    • Energy from power: kilowatt (kW) readings every hour sum to kilowatt-hours (kWh).
    • Water flow: liters per minute measured in a river give total volume.
    • Medicine: drug concentration samples give the area under the curve (AUC), a key dose measure.
    • Economics: marginal cost per unit adds up to total cost.
    InteractiveSpeed readings → distance traveled

    Riemann Sum Examples

    Common Riemann sum problems with n = 4 and their exact integrals.

    Riemann Sum Examples
    IntegralMethodSum (n = 4)ExactCalculator
    ∫02x2 dx\int_0^2 x^2\,dxLeft1.752.6667
    ∫02x2 dx\int_0^2 x^2\,dxRight3.752.6667
    ∫02x2 dx\int_0^2 x^2\,dxMidpoint2.6252.6667
    ∫0πsin⁡x dx\int_0^\pi \sin x\,dxMidpoint2.05232
    ∫131x dx\int_1^3 \frac{1}{x}\,dxTrapezoidal1.11671.0986
    ∫01ex dx\int_0^1 e^x\,dxRight1.9421.7183
    ∫04x dx\int_0^4 \sqrt{x}\,dxLeft4.14635.3333

    Popular Riemann Sum Problems

    Try each one, then reveal the answer or solve it in the calculator.

    1. Right Riemann sum of f(x) = x² + 1 on [0, 3] with n = 3.

      R_3,\ f(x)=x^2+1,\ [0,3]
      Show answerR_3 = 17
    2. Left Riemann sum of f(x) = 2x on [1, 5] with n = 4.

      L_4,\ f(x)=2x,\ [1,5]
      Show answerL_4 = 20
    3. Midpoint sum of f(x) = x³ on [0, 2] with n = 4.

      M_4,\ f(x)=x^3,\ [0,2]
      Show answerM_4 = 3.875
    4. Trapezoidal sum of f(x) = 1/(1+x²) on [0, 1] with n = 4. Multiply by 4 to estimate π.

      4\,T_4,\ f(x)=\tfrac{1}{1+x^2}
      Show answerT_4 \approx 0.7828,\ 4T_4 \approx 3.1312
    5. Right sum of f(x) = 9 − x² on [0, 3] with n = 6.

      R_6,\ f(x)=9-x^2,\ [0,3]
      Show answerR_6 = 15.625
    6. Left sum of f(x) = cos x on [0, π/2] with n = 3.

      L_3,\ f(x)=\cos x,\ [0,\tfrac{\pi}{2}]
      Show answerL_3 \approx 1.2388

    Explore More Sum Calculators

    Discover 67 free sum calculators across different categories. Find the right calculator for your needs.

    Browse All 67 Calculators
    Questions and answers

    Frequently Asked Questions

    What is a Riemann sum calculator?

    A Riemann sum calculator is an online tool that approximates a definite integral by adding the areas of n rectangles under f(x) on [a, b]. It returns the left, right, midpoint or trapezoidal sum with steps and a graph.

    How do you calculate a Riemann sum?

    Find Δx = (b − a)/n, choose a sample point in each subinterval, evaluate f at those points, add the values and multiply by Δx.

    Is the midpoint sum more accurate than the trapezoidal sum?

    Yes, usually. For smooth functions, the midpoint error is about half the trapezoidal error and has the opposite sign.

    What does n mean in a Riemann sum?

    n is the number of subintervals, which is the number of rectangles. A larger n gives a smaller Δx and a more accurate estimate.

    Can a Riemann sum be negative?

    Yes. Rectangles where f(x) is below the x-axis have negative height, so they subtract from the total.

    What is the difference between a Riemann sum and an integral?

    A Riemann sum is a finite approximation with n rectangles; the definite integral is the exact limit of those sums as n approaches infinity.

    When does a left Riemann sum overestimate?

    A left Riemann sum overestimates when f is decreasing on [a, b], since each rectangle takes the higher left-hand value.

    Which functions are Riemann integrable?

    Every continuous function on a closed interval [a, b] is Riemann integrable, as is every bounded function with finitely many discontinuities.

    Conclusion

    A Riemann sum turns the area under a curve into a sum of n rectangles, and the Riemann sum calculator does that work for any f(x), [a, b] and n. Use left or right sums to bracket the area of a monotonic function, midpoint or trapezoidal sums for accuracy, and raise n to drive the error toward 0.

    Not sure which rule to pick? Answer 3 questions below.

    InteractiveWhich Riemann sum should you use?