The Function picker on the left lists eight functions in three groups: Polynomial, Transcendental and Numerical only. Tapping one switches the curve and resets a, b and n to 0, 3 and 8; the chosen method stays. Learn more about the function families
The four Method buttons, Left, Right, Midpoint and Trapezoid, choose where each strip samples f; the shaded strips, the result card and the Explanation tab change at once. Learn more about the four methods
The Parameters sliders set lower bound a and upper bound b (from −8 to 8) and partitions n (from 1 to 80); the dashed grey lines follow a and b, sliding b below a flips the sign of the sum, and Reset restores a=0, b=3, n=8. Learn more about the a, b, and n sliders
The Riemann sum card under the plot shows Approximation Sₙ, True integral (closed form, or numeric for the two Numerical only functions) and Error=Sn−I; the Applied strip below repeats a, b, n and the rule. Learn more about reading the result card
The info panel has two tabs: Explanation works through the current setup and why the rule over- or undershoots, Concepts covers the four rules and convergence order. Learn more about the info panel
Riemann sum — an approximation of the definite integral∫abf(x)dx formed by partitioning [a,b] into n equal strips and summing the areas of simple shapes built on each strip.
Partition — the division of [a,b] into n subintervals of equal width Δx=(b−a)/n.
Sample point — the value of x on each strip where the function's height is evaluated. Determined by the rule: left endpoint, right endpoint, midpoint, or both endpoints (for trapezoid).
Left Riemann sum — sample at the left endpoint of each strip; uses rectangles.
Right Riemann sum — sample at the right endpoint of each strip; uses rectangles.
Midpoint rule — sample at the center of each strip; uses rectangles.
Trapezoid rule — average the function values at the two endpoints of each strip; uses trapezoids.
Convergence order — the rate at which the error shrinks as n grows. Left and right are O(1/n); midpoint and trapezoid are O(1/n2).
Getting Started
The page opens with the Quadratic family f(x)=x2 loaded, integrating from a=0 to b=3 with n=8 partitions using the Left rule. You see:
• The deep-blue curve of f across the integration window.
• Eight light-blue rectangles, each with its left edge touching the curve.
• Dashed gray vertical lines at a and b marking the bounds.
Below the graph, the result card shows three numbers side by side: the approximation Sn, the true integral, and the error. A small tag below the error labels the result as overshoots, undershoots, or exact.
To explore, switch between Left, Right, Midpoint, and Trapezoid in the Method section, drag the partitions n slider, or pick a different function family in the left panel.
The Four Methods
DemoThe four methods
Step 0 of 4
The Method section in the left panel offers four ways to build the approximation. Each samples the function at a different point on each strip:
• Left — sample at the left endpoint. On an increasing function every rectangle sits below the curve; on a decreasing function every rectangle sits above. Convergence order O(1/n).
• Right — sample at the right endpoint. Mirror image of left: overshoots on increasing, undershoots on decreasing. Same O(1/n) order.
• Midpoint — sample at the center. The flat top punches above the curve on one half of each strip and below on the other, so over- and under-shoots within each strip mostly cancel. Convergence order O(1/n2).
• Trapezoid — connect the left and right endpoint heights with a straight line. Errors also mostly cancel, opposite in sign to midpoint. Same O(1/n2) order.
Switching methods changes the picture immediately.
Left Rule: Every Rectangle Falls Short
On the tool's opening setup — f(x)=x2 from a=0 to b=3 with n=8 strips, so Δx=0.375 — the left rule takes each rectangle's height from the left edge of its strip.
S8=7.3828 against a true integral of 9, an error of −1.6172.
Because x2 is increasing across the whole interval, the left edge is the lowest point of every strip. Every rectangle sits under the curve, and the sum has to come in low.
Left rule, frozen at n = 8
Every rectangle top meets the curve at its left edge and falls away below it after that. The eight gaps between the tops and the curve are the -1.6172 of error, drawn to scale.
That undershoot is not a quirk of these numbers — it is guaranteed for any increasing function. Reverse the situation and the guarantee reverses with it: on a decreasing function the left rule overshoots by exactly the same reasoning.
The gaps between the rectangle tops and the curve are the error, laid out visually. Each one is roughly a triangle of width Δx and height f′(x)Δx, so halving Δx quarters each gap but doubles their number — leaving the total error only halved. That is the O(1/n) behaviour discussed under convergence and error.
Right Rule: Every Rectangle Overshoots
Same interval, same eight strips, height taken from the right edge instead.
S8=10.7578, an error of +1.7578.
On an increasing function the right edge is the highest point of each strip, so every rectangle pokes above the curve and the sum comes in high.
Right rule, frozen at n = 8
The mirror image: each top meets the curve at its right edge, so the whole strip sits above the curve. The overshoot of +1.7578 is the visible excess.
The two endpoint rules bracket the answer: 7.3828<9<10.7578. That is genuinely useful — on a monotonic function the left and right sums are a rigorous lower and upper bound, so the true value is trapped between them without any further argument.
Their average, (7.3828+10.7578)/2=9.0703, is precisely the trapezoid rule result. Averaging the two one-sided errors cancels most of what each gets wrong, which is why the trapezoid rule converges an order faster than either of the rules it is built from.
Midpoint Rule: Errors That Cancel Inside Each Strip
Height sampled at the centre of each strip rather than an edge.
S8=8.9648, an error of just −0.0352 — roughly fifty times smaller than either endpoint rule on the same eight strips.
Each rectangle now cuts through the curve rather than sitting under or over it: it is too low on the right half of its strip and too high on the left half, and the two halves very nearly cancel.
Midpoint rule, frozen at n = 8
Each rectangle now crosses the curve rather than clearing it, too high on one side of the strip and too low on the other. What is left over after they cancel is -0.0352.
That near-cancellation is what buys the extra order of accuracy. The midpoint rule is O(1/n2), so doubling the strip count cuts the error by about four rather than two.
There is a tidier way to see it. A midpoint rectangle has exactly the same area as the trapezoid formed by the tangent line at that midpoint, so the midpoint rule is really a tangent-line approximation in disguise. For a function curving one way throughout — as x2 does — that tangent lies below the curve, which is why the midpoint result lands slightly under the true value.
Trapezoid Rule: Joining the Sample Points
Instead of a flat top, each strip is capped by the straight line joining f at its two edges.
S8=9.0703, an error of +0.0703 — about twice the midpoint error, and in the opposite direction.
The shaded shapes are visibly slanted here, which is the one method where the outline follows the curve's direction rather than stepping across it.
Trapezoid rule, frozen at n = 8
The only method whose outline slants with the curve: each cap is the chord between the two strip edges. On an upward-curving function the chord rides above, giving +0.0703.
The sign is predictable. A chord across a strip of an upward-curving function lies above the curve, so the trapezoid rule overshoots whenever f′′>0 and undershoots whenever f′′<0. The midpoint rule errs the other way for the same reason, which is why the two bracket the answer: 8.9648<9<9.0703.
They also err in a fixed ratio — the trapezoid error runs about twice the midpoint error and opposite in sign. Combining them in the proportion that cancels both, 32⋅mid+trap, gives exactly 9 here. That combination is Simpson's rule, which is accurate to O(1/n4) in general and exact for any polynomial of degree three or less — so on x2 it lands on the true value with only eight strips.
The Function Families
DemoFunction families and the error tag
Step 0 of 5
Eight families are organized into three groups in the left panel.
• Gaussian bumpf(x)=e−x2/2 — the kernel of the normal distribution.
• Sincf(x)=sin(x)/x — appears in signal processing.
For the third group the "true" integral is computed numerically with a 4000-strip trapezoid.
The a, b, and n Sliders
DemoThe a, b and n sliders
Step 0 of 5
Three sliders in the Parameters section control the integration setup:
• lower bound a and upper bound b — the endpoints of the integration interval. The dashed gray lines at a and b on the graph follow the sliders. Setting b<a flips the sign of the integral; everything else still works.
• partitions n — the number of subintervals (and rectangles or trapezoids). Ranges from 1 to 80. As n grows, the rectangles get thinner, fill the area under the curve more tightly, and the error shrinks.
The most instructive experiment: fix a method, then slide n from low to high. Watch the error tag in the result card. With the left or right rule, doubling n roughly halves the error. With midpoint or trapezoid, doubling n shrinks the error by about a factor of four.
The Reset button next to Parameters restores the family defaults.
Reading the Result Card
The boxed card below the graph displays the three numerical results:
• Approximation Sₙ — the value of the Riemann sum at the current n and method.
• True integral — the exact value of ∫abf(x)dx. For polynomial and transcendental families this comes from a closed-form antiderivative. For numerical-only families it comes from a high-resolution trapezoid sum and is labeled accordingly.
• Error — the signed difference Sn−I. Positive means the Riemann sum is too high (overshoots); negative means too low (undershoots); near zero means the approximation has converged.
The header line above shows the method's formula symbolically, the current value of Δx, and which rule is active. Use the three numbers together: the approximation is what you computed, the true integral is what you wanted, and the error is the gap to close.
The Error Tag
Below the error number is a colored tag with one of three values:
• overshoots (red) — the Riemann sum is larger than the true integral. The error is positive. Common for the left rule on a decreasing function, or the right rule on an increasing function.
• undershoots — the Riemann sum is smaller than the true integral. The error is negative. Common for the left rule on an increasing function, or the right rule on a decreasing function.
• exact (green) — the absolute error is below the display threshold. Either you found a closed match (the trapezoid rule on a linear function is exact, for example) or n is large enough that the approximation has fully converged.
The endpoint rules (left, right) have predictable signs based on monotonicity. Midpoint and trapezoid usually err in opposite directions, which is why averaging them gives Simpson's rule — a more advanced technique.
Plot Size, Appearance and the Info Panel
DemoPlot size and info panel
Step 0 of 5
The row of buttons above the plot sets its size: S is 500×400, M is 700×550, L is 900×850 and XL is 1100×850 pixels. The current size is printed next to the buttons, and the page opens at 880×460. A new size redraws the same curve, strips and dashed lines; nothing about the sum changes.
Appearance, at the bottom of the left panel, holds one control: Strip color. The colour you pick fills the strips and tints the result card, the partitions n slider, the active Method button and the n and rule chips in the Applied strip. The Reset button next to Appearance returns to the default blue.
The info panel on the right has two tabs.
• Explanation follows the current setup. It gives the rule and its formula, then f, a, b, n and Δx, the values of Sn, the true integral and the error, a short paragraph on why the rule over- or undershoots here, and the rule's convergence order. It rewrites itself whenever you change the function, the method or a slider.
• Concepts does not change with the controls: what a Riemann sum is, the four rules, convergence order, signed areas, and what happens when there is no closed-form integral.
A Riemann sum approximates the area under a curve using simple geometric shapes. The procedure is:
• Split the interval [a,b] into n subintervals of equal width Δx=(b−a)/n.
• On each subinterval, pick a sample point xi∗ and use the function's value there as a height.
• Sum the areas of the resulting rectangles (or trapezoids):
Sn=i=1∑nf(xi∗)⋅Δx
The four classical rules differ only in where on each subinterval the sample point sits. As n→∞, the Riemann sum converges to the exact definite integral:
n→∞limSn=∫abf(x)dx
This limit is in fact the definition of the integral. The Fundamental Theorem of Calculus then provides the shortcut: evaluate an antiderivative at the endpoints instead of summing rectangles.
For full theoretical coverage, see the Riemann integral page.
Convergence and Error
The four rules differ not just in how they sample the curve, but in how fast the error shrinks as n grows.
Endpoint rules (Left and Right): error is O(1/n).
Each rectangle's flat top mismatches the curve's slope. Doubling n halves the strip width and roughly halves the error. To reduce the error by a factor of 100, you need n to grow by a factor of 100.
Midpoint and Trapezoid: error is O(1/n2).
Both rules sample more representatively. Midpoint takes the height at the center of each strip; trapezoid uses the linear interpolant between endpoint heights. In either case the over- and undershoots within a single strip largely cancel, so the leading-order error is in 1/n2 instead of 1/n. Doubling n shrinks the error by a factor of four. To reduce the error by 100, n only needs to grow by 10.
The practical lesson: choose the rule before you crank up n.
Signed Area
When the integrand dips below the x-axis, the function values become negative and the corresponding rectangles count as negative area. The tool draws them on the appropriate side of the axis and the Riemann sum subtracts them naturally.
This matches the standard convention for definite integrals: ∫abf(x)dx is the signed area between the curve and the x-axis, counting area above the axis positively and area below negatively. A function that's symmetric about the x-axis (like sinx over [−π,π]) has integral zero — positive and negative areas cancel.
Two other sign conventions are also handled correctly:
• If you set b<a, the strip width Δx=(b−a)/n goes negative, every term in the sum flips sign, and the result becomes −∫baf(x)dx. This is the standard ∫ab=−∫ba identity.
• If a=b, every strip has zero width and the sum collapses to zero.
Related Concepts
Definite integrals — the limit of Riemann sums as n→∞. The exact area the approximations are converging to.
Fundamental Theorem of Calculus — the shortcut for computing definite integrals: find an antiderivative, evaluate at the endpoints, subtract. See the FTC visualizer.
Simpson's rule — a higher-order rule that fits parabolas through groups of three points instead of rectangles or straight-line trapezoids. Convergence order O(1/n4).
Gaussian quadrature — an even higher-order family of numerical integration methods using carefully chosen sample points and weights. Used in production numerical libraries.
Improper integrals — integrals over unbounded intervals or with unbounded integrands. Defined as limits of ordinary integrals.
Average value of a function — equal to b−a1∫abf(x)dx. The mean of f over the interval.