Home › Calculators › Riemann Sum Calculator

Riemann Sum Calculator

Enter a function, an interval [a, b] and the number of subintervals n to approximate the area under the curve. See the left, right, midpoint or trapezoid rectangles drawn on the graph, the full table of sample points, the working, and how close each method gets to the true integral.

Last updated:

Examples:

Use x as the variable: ^, sqrt, ln, log, e^x, sin, cos, tan, abs, pi; 2x and 3sin(x) work too. a and b can be expressions like pi/2. Angles are in radians.

Left Riemann sum L₄ 1.75
f(x)Positive areaNegative area

Step-by-step

    Table of values

    How the sum converges as n grows

    Advertisement
    Advertisement

    How to use the Riemann Sum Calculator

    1. Type the function f(x), for example x^2, sin(x) or e^(-x^2).
    2. Enter the interval a and b (expressions like pi are allowed) and the number of subintervals n.
    3. Choose the method: Left, Right, Midpoint or Trapezoid. The sum and graph update instantly.
    4. Drag the n slider to watch the rectangles fill the area and the error shrink.
    5. Read the steps and table, compare the methods, and download the table as CSV if you need it.

    Riemann sum formulas

    With Δx = (b − a)/n and grid points xi = a + i·Δx for i = 0, 1, …, n:

    MethodFormulaError behaviour (smooth f)
    Left sum LₙΔx·[f(x₀) + f(x₁) + … + f(xₙ₋₁)]Proportional to 1/n
    Right sum RₙΔx·[f(x₁) + f(x₂) + … + f(xₙ)]Proportional to 1/n
    Midpoint sum MₙΔx·[f(m₁) + … + f(mₙ)], mᵢ = (xᵢ₋₁ + xᵢ)/2Proportional to 1/n²
    Trapezoidal Tₙ(Δx/2)·[f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ)]Proportional to 1/n², about twice the midpoint error
    Simpson Sₙ (n even)(Δx/3)·[f(x₀) + 4f(x₁) + 2f(x₂) + … + 4f(xₙ₋₁) + f(xₙ)]Proportional to 1/n⁴

    Worked example

    Approximate ∫₀² x² dx with n = 4. Here Δx = 0.5 and the grid is 0, 0.5, 1, 1.5, 2.

    • 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: (1.75 + 3.75)/2 = 2.75

    The exact value is 8/3 ≈ 2.6667, so the midpoint sum is closest, the trapezoid is slightly over, and the left and right sums miss by a full 0.92 and 1.08.

    Over- or underestimate?

    • Increasing f: left sum is too small, right sum is too big. Decreasing f: the reverse.
    • Concave up f (like x²): the trapezoid overestimates and the midpoint underestimates. Concave down: the reverse.
    • The exact integral always lies between the left and right sums when f is monotonic on [a, b], and between Mₙ and Tₙ when f keeps the same concavity.
    • Remember that AP-style notation LRAM, RRAM and MRAM mean the same as left, right and midpoint sums.

    Frequently asked questions

    What is a Riemann sum?

    A Riemann sum approximates the area under a curve, the definite integral of f from a to b, by splitting [a, b] into n subintervals of width Δx = (b − a)/n and adding up the areas of rectangles. Each rectangle's height is the function value at a chosen sample point in its subinterval.

    What is the difference between left, right and midpoint sums?

    They use different sample points. A left sum uses the left endpoint of each subinterval, x₀ to xₙ₋₁; a right sum uses the right endpoint, x₁ to xₙ; a midpoint sum uses the centre of each subinterval. For an increasing function the left sum underestimates and the right sum overestimates the area.

    How do you calculate a left Riemann sum by hand?

    Compute Δx = (b − a)/n, list the left endpoints a, a + Δx, …, a + (n − 1)Δx, evaluate f at each one, add the values 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.

    How is the trapezoidal rule related to Riemann sums?

    The trapezoidal sum is the average of the left and right sums: T = (L + R)/2. It joins neighbouring points with straight lines instead of flat tops, so T = (Δx/2)[f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ)].

    Which method is most accurate?

    For smooth functions the midpoint and trapezoidal sums are much more accurate than left or right sums: their error falls roughly by a factor of 4 each time n doubles, versus a factor of 2. Simpson's rule, a weighted combination of the two, is more accurate still. The convergence table shows these ratios for your function.

    What happens when the function is below the x-axis?

    Rectangles below the axis have negative height, so they subtract from the sum. A Riemann sum therefore approximates the signed (net) area. The graph shades negative parts in orange; to get total area, split the interval where f changes sign and add the absolute values.

    Why does the sum approach the integral as n grows?

    As n increases the rectangles get narrower, so they follow the curve more closely and the gaps or overlaps shrink. The definite integral is defined as the limit of Riemann sums as n → ∞ (for any choice of sample points), provided the function is integrable.

    Are all the tools on FreeToolCabin tested for quality and accuracy?

    Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

    Related tools

    Integral CalculatorDefinite integral of f(x) from a to b with adaptive Simpson, area graph and antiderivative.Derivative CalculatorSymbolic derivative of any f(x) up to 5th order, with steps, slope at a point and a graph.Graphing CalculatorPlot multiple functions with zoom, pan, intersections and a value table.Tangent Line CalculatorFind the tangent and normal line to f(x) at a point, with the derivative, slope and a graph.Percentage CalculatorWork out percentages, increases and decreases.Percentage Change CalculatorPercent increase or decrease between two values, and reverse.Percentage Difference CalculatorFind the percent difference between two values, with the formula.Ratio CalculatorSimplify, solve and scale ratios with step-by-step working.Proportion CalculatorSolve A/B = C/D for x with cross multiplication steps.Scientific CalculatorTrig, logs, powers and more in your browser.Fraction CalculatorAdd, subtract, multiply and divide fractions with steps.Multiplication Table GeneratorPrintable multiplication charts up to 30 × 30, single tables and practice sheets.Times Tables PracticeTimed times tables drills with a number pad, streaks and an accuracy heatmap.Fraction VisualizerInteractive fraction circles and bars: equivalents, comparing, adding and simplifying.Number Line GeneratorDraw number lines with any range, fractions or decimals, points, jumps and inequalities.Significant Figures CalculatorCount sig figs, round to any number of significant figures and do arithmetic with sig fig rules.Scientific Notation ConverterConvert numbers to and from scientific, engineering and E-notation, with exact digits and SI prefixes.Caffeine CalculatorAdd up daily caffeine, compare it with 400 mg and see how much is left at bedtime.Percent Error CalculatorPercent error between experimental and theoretical values, for one result or several trials.Rounding CalculatorRound to decimal places, significant figures or the nearest 10, 100 or 0.5, any rule.Long Division CalculatorDivide with quotient, remainder, decimals and a step-by-step long division layout.Cube Root CalculatorFind cube roots and nth roots, check perfect cubes and simplify radicals.2-Stroke Oil Mix CalculatorHow much 2-stroke oil to add to gas for 50:1, 40:1, 32:1 and more, in fl oz or ml.Math Worksheet GeneratorCreate printable addition, subtraction, multiplication and division worksheets with answer keys.Simplify Fractions CalculatorReduce any fraction to lowest terms with GCD steps, mixed number, decimal and equivalents.Complex Number CalculatorAdd, subtract, multiply, divide complex numbers; polar form, modulus, argument, powers and roots.Big Number CalculatorExact + − × ÷ mod and powers for huge integers with hundreds of digits, plus digit count.Three-Phase Power CalculatorkW, kVA and kVAR from volts, amps and power factor, or three-phase current from kW or kVA.Compression Ratio CalculatorStatic engine compression ratio from bore, stroke, chamber, gasket, deck and piston volume.Expanded Form CalculatorWrite any number or decimal in expanded form, word form and a place value chart.Mixed Number CalculatorAdd, subtract, multiply and divide mixed numbers, or convert improper fractions, with steps.Nth Root CalculatorAny root of any number: real nth root, simplified radical and all complex roots.Long Multiplication CalculatorMultiply whole numbers or decimals with the column method shown digit by digit.Matrix Multiplication CalculatorMultiply matrices up to 8×8 with every dot product shown, exact fractions and a size check.Order of Operations Calculator (PEMDAS)Solve arithmetic expressions step by step with PEMDAS/BODMAS, brackets, powers and fractions.Virtual Base Ten BlocksDrag ones, rods, flats and cubes onto a place value mat to model regrouping, addition and subtraction.Compare Fractions CalculatorCompare two or more fractions with <, > or = and put them in order, with steps.Equivalent Fractions CalculatorList equivalent fractions, check if two are equal, or find a missing number, with bars.PSAT Score CalculatorEstimate your PSAT/NMSQT section scores, total score and National Merit Selection Index.Rational Expressions CalculatorSimplify, add, subtract, multiply and divide rational expressions with excluded values.Rationalize the Denominator CalculatorRemove square roots and cube roots from a denominator, with conjugates and full steps.Reverse Percentage CalculatorFind the original value before a percentage increase or decrease, or the whole from a part.Sum CalculatorPaste any list or column of numbers to get the total, count, average, min and max instantly.Unit Rate CalculatorFind the unit rate (per 1) from two quantities, compare rates and see the steps.Map Scale CalculatorConvert map distance to real distance and back for scales like 1:24,000 or 1 in = 1 mi.Math Formulas Cheat SheetSearchable algebra, geometry, trig, calculus and statistics formulas with a printable sheet.Number Properties CalculatorIs it prime, perfect, square, triangular or Fibonacci? See every property of a number.Paper Tape CalculatorAdding machine calculator with a running paper tape: edit entries, subtotals, notes, print or export.Pi Digits CalculatorCalculate π to up to 100,000 digits, find any number or your birthday in pi, and download it.
    See all 46 Arithmetic & Number Calculators →