From the workbench / Mathematics

Choosing a numerical integration method

Compare midpoint, trapezoid, and Simpson rules on a known integral, then use refinement to judge a result when the exact answer is unavailable.

Open numerical integration calculator

Match the rule to the function

The midpoint rule samples the centre of each subinterval. The trapezoidal rule joins endpoint samples with straight lines. Simpson rules use polynomial panels: quadratics for 1/3 and cubics for 3/8.

For a smooth function, Simpson rules can reach a useful accuracy with fewer subintervals than lower-order rules. That advantage depends on the function behaving smoothly; a narrow peak or a singularity can defeat a coarse sampling grid.

Count subintervals, not sample points

The input n is the number of equal subintervals between the bounds. Composite Simpson 1/3 requires an even n; Simpson 3/8 requires n to be a multiple of three. A count such as 12 works with either rule.

Enter functions with explicit multiplication, such as 2*x, and use ^ for powers. The typeset preview shows how the expression was parsed. Angles are in radians. The tool evaluates the entered function, rather than integrating an uploaded table of measurements.

h=(b−a)n

Compare against an integral we know

For x³ from 0 to 1, the exact integral is 1/4. With six subintervals, midpoint gives about 0.246528 and trapezoid gives 0.256944. Both Simpson rules return 0.25 to floating-point rounding because their polynomial exactness includes cubics.

At twelve subintervals, midpoint gives about 0.249132 and trapezoid gives 0.251736. Their absolute errors are a quarter of the six-subinterval errors in this example. It is a useful check on both the calculation and the interpretation of n.

f(x)=x3
I=14=0.25
Integral of x³ over [0, 1]; displayed values rounded
Rulen = 6n = 12
Midpoint0.2465280.249132
Trapezoid0.2569440.251736
Simpson 1/30.250.25
Simpson 3/80.250.25

Refine before trusting the digits

When the exact answer is unknown, repeat with a larger valid n and compare. Agreement between two grids is evidence worth checking, not a proof: both grids can miss the same narrow feature. Compare methods and inspect the function over the whole interval.

For sufficiently smooth functions, standard composite midpoint and trapezoidal error bounds depend on a bound for the second derivative; Simpson 1/3 uses a fourth-derivative bound. The calculator does not establish those derivative bounds or certify an error tolerance.

An interval crossing a discontinuity or an improper endpoint needs separate mathematical treatment. Even if a rule happens not to sample the troublesome point, a finite answer does not establish that the integral exists. Split at known breaks and use a method appropriate to each resulting integral.

References & further reading

Equations describe the stated model. Worked values are rounded for reading; the calculator’s download retains its calculated precision. Read about our checks and their limits.

Try the example, then change one input at a time.

Open calculator More guides