Numerical Integration Calculator (Trapezoidal & Simpson)

Estimate a definite integral from data points with the trapezoidal rule and Simpson's 1/3 rule. Enter y-values with a spacing h, or x, y pairs.

At least 2 values. Use a point for decimals (1.5), no thousands separators, and separate numbers with spaces or a comma and a space.
Must be greater than 0. The first point is x₀, the integral runs over n × h.

Results

Trapezoidal rule
22
Sum of (Δx × (yᵢ + yᵢ₊₁) ÷ 2) over every interval.
Simpson’s 1/3 rule
21.333
Usually more accurate than the trapezoidal rule for smooth data.
Number of intervals (n)
4
Range of x integrated over
0 to 4
Spacing h
1

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.

Trapezoidal: T = h/2 × [y₀ + 2y₁ + 2y₂ + … + 2yₙ₋₁ + yₙ] Simpson 1/3: S = h/3 × [y₀ + 4y₁ + 2y₂ + 4y₃ + … + 4yₙ₋₁ + yₙ] (n must be even)

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

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