How to use it
- Type f(x), for example
x^2. - Enter the interval [a, b] and the number of subintervals n.
- Pick the method you need; all the others are listed too, with the exact integral for comparison. For n up to 40 the sample points and values are listed.
How it works
With Δx = (b − a)/n and xᵢ = a + iΔx:
- Left: Δx · [f(x₀) + f(x₁) + … + f(xₙ₋₁)]
- Right: Δx · [f(x₁) + … + f(xₙ)]
- Midpoint: Δx · Σ f((xᵢ + xᵢ₊₁)/2)
- Trapezoidal: Δx/2 · [f(x₀) + 2f(x₁) + … + 2f(xₙ₋₁) + f(xₙ)]
- Simpson (n even): Δx/3 · [f(x₀) + 4f(x₁) + 2f(x₂) + … + 4f(xₙ₋₁) + f(xₙ)]
The exact value is computed separately by adaptive Simpson integration to about ten digits.
Worked example
f(x) = x² on [0, 2] with n = 4, so Δx = 0.5 and f at 0, 0.5, 1, 1.5, 2 is 0, 0.25, 1, 2.25, 4.
- 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
- Trapezoidal: (1.75 + 3.75)/2 = 2.75
- Simpson: 0.5/3 · (0 + 1 + 2 + 9 + 4) = 2.666666667
The integral is 8/3 = 2.666666667, so the midpoint error is −0.04166666667 and Simpson’s rule is exact, as expected for a quadratic.
Tips and common mistakes
- n is the number of rectangles, not the number of points: n subintervals use n + 1 endpoints.
- Doubling n should cut the midpoint and trapezoid errors by about 4 and Simpson’s error by about 16 for smooth functions.
- If f is not finite somewhere in [a, b], for example 1/x across 0, the sums are meaningless and the calculator reports the point.