Skip to content
Calculator Collection

Rectangular Rule Integration

Approximate a definite integral using a rectangular (midpoint-style) rule with a chosen number of subintervals and an averaged function value. Returns the area of a single representative rectangle of width Δx.

Last updated: May 2026

Compare with similar

About this calculator

This calculator implements a one-rectangle approximation: Approx Integral = (b − a) / n × functionValue, where a is the lower bound, b is the upper bound, n is the number of subintervals, and functionValue is a representative height (typically the mean of f sampled at one or more interior points). The expression (b − a)/n is the width Δx of each subinterval; multiplying by a single height gives the area of one rectangle. The full Riemann sum for an integral approximation is Σ f(x_i) · Δx summed over all n subintervals — this tool computes just one such term, useful for understanding the building block of Riemann sums or for a single-rectangle approximation when you already know a representative average. Edge cases: if b < a the result is negative, matching the convention ∫_b^a f = −∫_a^b f. If n = 0 the formula divides by zero and returns infinity or NaN. The accuracy of this single-rectangle estimate depends entirely on how representative your supplied functionValue is — choosing the midpoint of f over [a,b] gives the midpoint-rule estimate (b−a)·f((a+b)/2), which has error O(Δx²) for smooth functions. For real Riemann-sum integration with many subintervals, use a dedicated Riemann-sum calculator that evaluates f at each sample point automatically.

How to use

Example 1 — midpoint estimate of ∫₀² 3 dx. Constant function f(x) = 3 on [0, 2] with n = 4 subintervals. Width per subinterval: (2 − 0) / 4 = 0.5. Inputs: lowerBound 0, upperBound 2, intervals 4, functionValue 3. Result: 0.5 × 3 = 1.5. Verify: the true integral of a constant 3 from 0 to 2 is 3 · 2 = 6; this calculator returns the area of one rectangle of width 0.5 and height 3, so to get the full integral you would multiply by n = 4: 1.5 × 4 = 6 ✓. The tool is computing one of n Riemann-sum terms, not the full sum. Example 2 — single-rectangle estimate of ∫₀^π sin(x) dx. Average value of sin on [0, π] is 2/π ≈ 0.6366. Using n = 1 (treat the whole interval as one rectangle): lowerBound 0, upperBound π ≈ 3.1416, intervals 1, functionValue 0.6366. Width: 3.1416 / 1 = 3.1416. Result: 3.1416 × 0.6366 ≈ 2.0. Verify: ∫₀^π sin(x) dx = 2 exactly ✓. Using n = 1 with the true mean value gives the exact integral by the mean-value theorem for integrals; with n > 1 the result is only one rectangle's area and must be multiplied by n (or summed over all rectangles) to estimate the full integral.

Frequently asked questions

How is this different from a full Riemann sum?

A full Riemann sum approximates the integral ∫_a^b f(x) dx as a sum Σ f(x_i) · Δx over n rectangles, where each rectangle has width Δx and height f(x_i) sampled at a chosen point in the i-th subinterval. Sample points can be left endpoints, right endpoints, midpoints, or any other rule, and the choice gives left, right, or midpoint Riemann sums respectively. This calculator computes only one such term: Δx · functionValue, the area of a single rectangle of width Δx and height equal to your supplied function value. To get a real Riemann-sum approximation of the full integral you must evaluate f at each sample point and sum the resulting areas yourself — this tool does not iterate. The advantage of this single-term approach is that it isolates the building block of integration and lets you reason about the role of Δx and the chosen height; the disadvantage is that you cannot use it directly to approximate an integral unless you supply a representative average and remember to multiply by n (or use n = 1 for a single-rectangle estimate covering the whole interval).

What's the difference between left, right, midpoint, and Simpson's rules?

These are all methods for approximating ∫_a^b f(x) dx via finite sums, differing in where the function is sampled. Left-rectangle rule samples f at the left endpoint of each subinterval; right-rectangle rule at the right endpoint; midpoint rule at the centre. Midpoint typically has the smallest error of the three, with O(Δx²) convergence for smooth functions versus O(Δx) for left/right. Trapezoidal rule averages left and right endpoints (also O(Δx²)), and Simpson's rule fits a parabola through groups of three points for O(Δx⁴) accuracy — quartic-rate convergence makes Simpson dramatically more efficient for smooth functions. For this calculator's one-rectangle setup, supplying the midpoint of [a,b] as functionValue with n = 1 gives the midpoint-rule estimate of the full integral; supplying f(a) or f(b) gives left- or right-rectangle estimates. For real numerical integration, prefer trapezoidal or Simpson's via a dedicated calculator.

How many subintervals should I use for a good approximation?

Error in rectangle-rule integration scales roughly as 1/n for left/right rules and 1/n² for midpoint and trapezoidal rules, so doubling n cuts the error roughly in half (left/right) or to a quarter (midpoint/trapezoidal). For most smooth, well-behaved functions, n = 100 to n = 1000 produces machine-precision results with midpoint or trapezoidal rules. For functions with sharp peaks, near-discontinuities, or rapid oscillation, much higher n (or adaptive quadrature that places more points where curvature is high) is needed. As a rough rule: if doubling n halves the change in the estimate, you're in the smooth O(Δx²) regime; if doubling n only modestly improves the estimate, the function has features that require either more sophisticated quadrature or refinement of the integration region. This single-rectangle tool cannot benefit from n directly because it only computes Δx; for that benefit you need a multi-term Riemann-sum calculator.

What are the common mistakes when using rectangle-rule integration?

The biggest mistake here is misunderstanding that the result is one rectangle's area, not the full integral approximation — to get the full sum you must either set n = 1 with the true mean value or multiply the calculator's output by n (assuming functionValue is the average of f over [a,b]). The second is supplying a function value sampled at the endpoint when you wanted the midpoint, leading to systematic over- or under-estimation. The third is using too few subintervals on functions with sharp curvature or oscillation, where the rectangle approximation misses entire features between sample points. People also flip the bounds (b < a) without recognising that the negative result is correct by convention. Finally, choosing very large n with extreme bounds can produce floating-point underflow in Δx; for most practical integrals, n between 10 and 10,000 is sensible, and beyond that point you're either using a smoother method (Simpson's, Gauss-Legendre) or there's no benefit.

When should I not use this calculator?

Do not use it for actual production numerical integration — it computes only one rectangle and is too primitive for any serious task. Use a dedicated Riemann-sum, trapezoidal-rule, Simpson's-rule, or adaptive-quadrature calculator instead. It is not appropriate for functions with sharp peaks, near-discontinuities, asymptotes, or oscillatory behaviour, where the rectangle method's accuracy degrades dramatically and adaptive or specialised methods (Gauss-Legendre, Clenshaw-Curtis, Filon) are needed. Do not use it for improper integrals (infinite bounds or integrands with singularities at the endpoints), which require limit-based or transformed quadrature methods. Avoid it for multi-dimensional integrals; for those use Monte Carlo or tensor-product quadrature. Finally, do not use it for analytical integrals that have a closed-form antiderivative — symbolic integration (Wolfram Alpha, SymPy, hand calculation via the Fundamental Theorem of Calculus) is exact and faster.

Sources & references