Rectangular Rule: Approximating an Integral With Rectangles
Many functions have no neat antiderivative, so their definite integrals are approximated numerically. The simplest method covers the region under the curve with rectangles of equal width and adds up their areas: the rectangular rule, also called a Riemann sum. This guide shows how it works, works through a midpoint example, and explains how the choice of height and the number of strips control the error.
What the Rectangular Rule Is and Why It Matters
A definite integral measures the signed area between a curve and the horizontal axis over an interval from a lower bound to an upper bound. The rectangular rule approximates that area by slicing the interval into equal-width strips and treating each strip as a rectangle. The width of every rectangle is the same — call it Δx — and the height is the value of the function somewhere within that strip.
It matters because many functions met outside a textbook have no closed-form antiderivative. The integral of e^(−x²), which underlies the normal distribution, cannot be written with elementary functions, so it is evaluated numerically. The rectangular rule is the foundation of that family of methods and the first one students learn because it makes the idea concrete: the integral is a sum of rectangle areas, and the sum approaches the true value as the rectangles get thinner.
How to Calculate with the Rectangular Rule
The core building block is the area of a single representative rectangle:
Rectangle Area = Δx × f(x), where Δx = (Upper Bound − Lower Bound) ÷ Number of Intervals
The width Δx comes from dividing the total interval into equal pieces, and the height f(x) is a representative function value for that piece. In the midpoint version of the rule — usually the most accurate of the simple choices — you evaluate the function at the center of each strip. The full integral estimate is the sum of all such rectangle areas across the interval.
Worked example. Suppose you want to approximate the area under f(x) = x² from x = 0 to x = 4 using 4 intervals.
1. Compute the width: Δx = (4 − 0) ÷ 4 = 1
2. The four strips span [0,1], [1,2], [2,3], [3,4], with midpoints 0.5, 1.5, 2.5, and 3.5
3. Evaluate the function at each midpoint: f(0.5) = 0.25, f(1.5) = 2.25, f(2.5) = 6.25, f(3.5) = 12.25
4. Multiply each height by the width and sum: 1 × (0.25 + 2.25 + 6.25 + 12.25) = 21
The exact answer is 4³ ÷ 3 = 21.333…, so four midpoint rectangles land within about 1.6% of the truth. (Left endpoints would give 1 × (0 + 1 + 4 + 9) = 14 and right endpoints 1 × (1 + 4 + 9 + 16) = 30, which shows how much the choice of height matters.)
The Rectangular Rule Integration calculator computes one building block of this sum: enter the bounds, the number of intervals and one function value, and it returns the area of that single rectangle, Δx × f(x). To approximate the whole integral you add up one such term for each strip, or use n = 1 with the function's average value over the interval. For the full sum done automatically on a power function c·xⁿ, with left, right or midpoint heights, use the Riemann Sum Calculator.
Using the Rule Well: Accuracy and Variants
The single biggest control you have over accuracy is the number of intervals. For a smooth function the error of a left- or right-endpoint sum is proportional to the strip width, so doubling the number of intervals roughly halves it. The midpoint rule's error is proportional to the width squared (the bound is M(b − a)³ ÷ 24n², where M is the largest |f″| on the interval), so doubling the intervals cuts its error by about a factor of four. In the example, going from 4 to 8 midpoint strips moves the estimate from 21 to 21.25, an error of 0.083 instead of 0.333.
Where you take the height matters too. Using the left endpoint of each strip, the right endpoint, or the midpoint gives three different estimates. For a function that is increasing, left endpoints systematically undershoot the true area and right endpoints overshoot it, while the midpoint tends to split the difference and is markedly more accurate. When precision matters, prefer the midpoint.
It also helps to know where the rectangular rule struggles. Sharp peaks, rapid oscillations and discontinuities defeat a coarse grid, because a single rectangle cannot follow detail finer than its own width. There, you either pack in many more intervals or step up to a method that fits the curve better, such as the trapezoidal rule, which replaces each rectangle's flat top with a sloped one.
Common Mistakes and How to Avoid Them
Miscomputing Δx. The width is the total interval length divided by the number of intervals, not by the number of points. With 4 intervals over [0, 4], Δx is 1, not 0.8.
Mixing up endpoints and midpoints. Decide which evaluation point you are using and apply it consistently to every strip. Silently switching between left endpoints and midpoints corrupts the sum.
Using too few rectangles on a curvy function. A handful of strips is fine for a gentle curve but wildly off for a wiggly one. When in doubt, increase the interval count and watch whether the estimate stabilizes.
Forgetting that area can be negative. Where the function dips below the axis, its rectangles contribute negative area. The rule returns signed area, which is correct for an integral but not the same as total geometric area.
Expecting an exact answer. The rectangular rule is an approximation by design. Treat its output as an estimate whose accuracy you control through the number of intervals, not as the exact integral.
Key takeaways
• Know the building block: Rectangle Area = Δx × f(x), where Δx = (Upper Bound − Lower Bound) ÷ Number of Intervals, summed across all strips
• Add intervals for accuracy: Doubling the interval count roughly halves the error of an endpoint sum and quarters the error of the midpoint rule
• Prefer the midpoint: Midpoint heights are usually far more accurate than left- or right-endpoint heights for the same number of rectangles
• Treat it as an estimate: The Rectangular Rule Integration calculator returns one rectangle's area, Δx × f(x); the integral estimate is the sum over all strips, and it is signed area