How it’s calculated
Numerical integration estimates a definite integral ∫f(x)dx when you only know f at a set of points, for example from a table of measurements. Both rules split the range into n intervals of width h.
The trapezoidal rule joins neighboring points with straight lines and adds up the trapezoids. Simpson's rule fits a parabola through each pair of intervals, which is usually much more accurate for smooth data, and exact for polynomials up to degree 3. It needs an even number of intervals (an odd number of points) and equal spacing; the calculator tells you when that is not the case. With x, y pairs of uneven spacing only the trapezoidal rule is used.
Example: f(x) = x² sampled at x = 0, 1, 2, 3, 4 gives y = 0, 1, 4, 9, 16 and h = 1. T = 1/2 × (0 + 2 + 8 + 18 + 16) = 22. S = 1/3 × (0 + 4 + 8 + 36 + 16) = 21.3333, which is exactly ∫₀⁴ x² dx = 64/3, since Simpson's rule is exact for a parabola. The trapezoids overestimate here because the curve bends upward.
Frequently asked questions
Which is more accurate, trapezoidal or Simpson’s rule?
For smooth data Simpson’s rule is usually far more accurate with the same points. The trapezoidal rule is simpler and works with any spacing.
Why does Simpson’s rule need an even number of intervals?
It fits one parabola through each pair of neighboring intervals, so intervals must come in pairs. With an odd number, drop or add a point, or use the trapezoidal result.
Can the x-values be unevenly spaced?
Yes for the trapezoidal rule: choose “x, y pairs”. Simpson’s 1/3 rule as used here needs equal spacing.
How do I get more accuracy?
Use more points (a smaller h). The trapezoidal error shrinks roughly with h², and Simpson’s with h⁴, for smooth functions.
Embed this calculator
Add this free calculator to your own website. Copy the code below into your page’s HTML:
Need this calculator branded, changed or built around your own prices?See custom business solutions →
Sources
- Calculus Volume 2, §3.6 Numerical Integration (trapezoidal rule and Simpson’s rule) — OpenStax
- NIST Digital Library of Mathematical Functions, §3.5 Quadrature (trapezoidal and Simpson rules) — NIST
Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.
Added · Last updated · How we check our calculators
Spotted a mistake or missing option? Report a problem· Suggest a calculator