A Riemann sum approximates the definite integral of a function by dividing the region under the curve into a finite number of rectangles and summing their areas. It is the foundation of integral calculus and gives you a concrete way to see how the exact integral emerges as the number of rectangles grows without limit. The three most common versions differ only in where on each subinterval you sample the function to set the rectangle height. The left Riemann sum samples the left endpoint of each subinterval, the right sum samples the right endpoint, and the midpoint sum samples the centre. For an increasing function the left sum will underestimate and the right sum will overestimate the true area, with the midpoint sum generally splitting the error and converging fastest. This calculator accepts any function of x in standard notation, the lower limit a and upper limit b of integration, and the number of rectangles n. It returns the left sum, the right sum, and the midpoint sum simultaneously so you can see how the three approximations compare. You can use standard operators +, -, *, / and ^ for powers, along with functions such as sin, cos, exp, log, sqrt, and abs. Increase n to watch all three sums converge toward the true integral. The default example uses f(x) = x^2 from 0 to 3 with 6 rectangles, which gives a clear demonstration of the difference between the three methods.
Exact integral uses Simpson's rule with 1000 subintervals for reference. Use ^ for powers and * for multiplication.
The interval [a, b] is divided into n equal subintervals each of width dx = (b - a) / n. For the left sum, the height of each rectangle is f evaluated at the left edge of the subinterval: f(a + i * dx) for i from 0 to n-1. For the right sum, the height is f(a + (i+1) * dx) for i from 0 to n-1. For the midpoint sum, the height is f at the centre: f(a + (i + 0.5) * dx). Each sum multiplies the rectangle height by dx and accumulates the total. The exact reference uses Simpson's rule with 1000 subintervals, which is accurate to many decimal places for smooth functions.
For f(x) = x^2 from a = 0 to b = 3 with n = 6 rectangles, each rectangle has width dx = 0.5. The left endpoints are 0, 0.5, 1, 1.5, 2, 2.5 and the left sum is (0 + 0.25 + 1 + 2.25 + 4 + 6.25) * 0.5 = 6.875. The right endpoints are 0.5, 1, 1.5, 2, 2.5, 3 and the right sum is (0.25 + 1 + 2.25 + 4 + 6.25 + 9) * 0.5 = 11.375. The midpoints are 0.25, 0.75, 1.25, 1.75, 2.25, 2.75: f values are 0.0625, 0.5625, 1.5625, 3.0625, 5.0625, 7.5625. Sum * 0.5 = (0.0625 + 0.5625 + 1.5625 + 3.0625 + 5.0625 + 7.5625) * 0.5 = 17.875 * 0.5 = 8.938. The true integral of x^2 from 0 to 3 is exactly 9, shown by Simpson's rule reference.
If you've found a bug, or would like to contact us, or learn more about James Graham and Calculate.co.nz.
Calculate.co.nz is partnered with Interest.co.nz for New Zealand's highest quality calculators and financial analysis.
Calculate.co.nz is the sister site of CalculatorHub.com, the world's largest calculator website by tool count.
All calculators and tools are provided for educational and indicative purposes only and do not constitute financial advice.
Calculate.co.nz is proudly part of the Realtor.co.nz group, New Zealand's leading property transaction literacy platform, helping Kiwis understand the home buying and selling process from start to finish. Whether you're a first home buyer navigating your first property purchase, an investor evaluating your next acquisition, or a homeowner planning to sell, Realtor.co.nz provides clear, independent, and trustworthy guidance on every step of the New Zealand property transaction journey.
Calculate.co.nz is also partnered with Health Based Building and Premium Homes to promote informed choices that lead to better long-term outcomes for Kiwi households.
Calculate.co.nz is hosted in Auckland by SiteHost New Zealand.
All content on this website, including calculators, tools, source code, and design, is protected under the Copyright Act 1994 (New Zealand). No part of this site may be reproduced, copied, distributed, stored, or used in any form without prior written permission from the owner.
About & trust: Why Calculate is NZ's most comprehensive · By the Numbers · How we compare · Editorial standards · How we keep data current · NZ finance glossary · Research & data · Financial literacy NZ · About · Privacy policy · Terms of use
Reviewed and maintained. Last reviewed 2026-07-27 and checked on a twice-monthly cycle against IRD, RBNZ and Stats NZ. How we keep data current.
© 2026 Calculate.co.nz. All rights reserved. Building free NZ calculators since 2011.