Numerical Integration Calculator
Evaluate a definite integral numerically by the trapezoidal rule, Simpson's 1/3 rule or Simpson's 3/8 rule, from a function or a table of values, with the ordinates, weights and the error against an accurate value.
About the Numerical Integration Calculator
Split [a, b] into n equal intervals of width h = (b − a)/n and take the ordinates y₀, y₁, …, yₙ. The trapezoidal rule joins them with straight lines: (h/2)[(y₀ + yₙ) + 2(y₁ + … + yₙ₋₁)]. Simpson's 1/3 rule fits parabolas through each pair of intervals, so n must be even: (h/3)[(y₀ + yₙ) + 4(odd ordinates) + 2(even ordinates)]. Simpson's 3/8 rule fits cubics through groups of three intervals, so n must be a multiple of 3.
For a function, the answer is compared with an accurate value from adaptive quadrature, so you can see each rule's error.
The formula
Simpson's 1/3: ∫ y dx ≈ (h/3)[(y₀ + yₙ) + 4(y₁ + y₃ + …) + 2(y₂ + y₄ + …)]
Worked example
∫ dx/(1 + x²) from 0 to 1, n = 6, h = 1/6
- y₀ = 1, y₆ = 0.5; odd ordinates sum 2.3409…; even 1.5600…
- (1/18)[1.5 + 4(2.34089) + 2(1.56)] ≈ 0.785398
- Exact: π/4 = 0.785398163…
Questions people ask
Which rule is most accurate?
For smooth functions Simpson's rules are far more accurate than the trapezoidal rule for the same n: their error shrinks like h⁴ rather than h².
Why must n be even for Simpson's 1/3 rule?
It fits one parabola over each pair of intervals, so the intervals must pair up.