Numerical Computation

Trapezoidal Rule and Simpson Rule: Numerical Integration

Numerical Computation Study guides

When an integral has no easy antiderivative, approximate it. Learn the composite trapezoidal rule, Simpson 1/3 rule, their formulas, error order and a worked example.

Numerical integration approximates the definite integral of f from a to b using values of f at equally spaced points. Split [a, b] into n sub-intervals of width h = (b - a) / n, with points x0 = a, x1, up to xn = b. This is needed when the antiderivative is unknown or the function is given only as a table of values.

The composite trapezoidal rule replaces the curve on each sub-interval by a straight line. The result is T = (h / 2) x [f(x0) + 2 f(x1) + 2 f(x2) + ... + 2 f(x(n-1)) + f(xn)]. The error is proportional to h^2, so halving h cuts the error by about four. Simpson 1/3 rule replaces the curve by parabolas through three consecutive points, and it requires n to be even. S = (h / 3) x [f(x0) + 4 f(x1) + 2 f(x2) + 4 f(x3) + ... + 4 f(x(n-1)) + f(xn)]. The weights alternate 4 and 2 between the end points, which have weight 1. The error is proportional to h^4, so Simpson is far more accurate for smooth functions at the same cost.

Remember the checks. Count the intervals: trapezoidal works for any n, Simpson 1/3 needs an even n (an odd number of points). Simpson 3/8 rule uses cubics and needs n divisible by 3. The trapezoidal rule is exact for linear functions and Simpson 1/3 is exact for polynomials up to degree 3.

Key points

  • h = (b - a) / n.
  • Trapezoidal: (h/2)[first + 2 x middle terms + last], error order h^2.
  • Simpson 1/3: (h/3)[first + 4 odd + 2 even + last], n even, error order h^4.
  • Simpson 1/3 is exact up to cubic polynomials.
  • Use tables of values when no antiderivative exists.

Worked example

Approximate the integral of x^2 from 0 to 2 with n = 4, so h = 0.5. Values: f(0) = 0, f(0.5) = 0.25, f(1) = 1, f(1.5) = 2.25, f(2) = 4. Trapezoidal: (0.5 / 2) x [0 + 2(0.25 + 1 + 2.25) + 4] = 0.25 x 11 = 2.75. Simpson 1/3: (0.5 / 3) x [0 + 4(0.25) + 2(1) + 4(2.25) + 4] = (0.1667) x 16 = 2.6667. The exact value is 8/3 = 2.6667, so Simpson is exact here.

Common questions

Why does Simpson 1/3 need an even number of intervals?

It fits a parabola through each pair of intervals (three points), so the intervals must pair up.

Which is more accurate, trapezoidal or Simpson?

Simpson 1/3, with error of order h^4 against h^2 for the trapezoidal rule.

Related topics

BASMAGLY is an independent student project, not an official Delta University site. Check lectures and your instructor for the final word.