Numerical integration and differentiation · Definition
Simpson's rule
Before you start you need to know
When the trapezoidal rule is too imprecise, Simpson's rule improves the approximation by using parabolas instead of straight lines. It relies on polynomial interpolation to build that quadratic fit.
Definition
Simpson's rule is a numerical quadrature method that approximates \(\int_a^b f(x)\,dx\) by integrating a quadratic polynomial that interpolates \(f\) at \(a\), \(\frac{a+b}{2}\), and \(b\).
The composite Simpson's rule divides \([a,b]\) into an even number \(n\) of subintervals of width \(h=\frac{b-a}{n}\) and applies the simple rule to each pair of subintervals. Its error is of order \(O(h^4)\), and the simple rule is exact for polynomials up to degree 3, an advantage over the trapezoidal rule, which is only exact for degree 1. The error term depends on the fourth derivative \(f^{(4)}\), so the formula gains accuracy on smooth functions.
To approximate \(\int_0^2 x^4\,dx\) with the simple rule, take \(f(0)=0\), \(f(1)=1\), and \(f(2)=16\). Then \(\frac{1}{3}\left[0+4(1)+16\right]=\frac{20}{3}\approx 6.67\), compared with the exact value \(\frac{32}{5}=6.4\). The result shows the approximation and its error without subdividing the interval.
A typical mistake is forgetting that the composite rule requires an even number of subintervals and applying the formula with odd \(n\), which produces an invalid approximation. Another common error is using the weights \(1,4,1\) without multiplying by \(\frac{h}{3}\), which scales the result incorrectly. Checking that the width \(h\) matches the chosen partition avoids both problems.
Think about it
Why does the simple Simpson's rule integrate cubics exactly if it only uses a parabola?
Because the nodes and weights are symmetric about the midpoint, and the error depends on \(f^{(4)}\), which is zero for any cubic.
Exercises 10
- How many subintervals does the composite Simpson's rule require?
- What polynomial degree does the simple Simpson's rule integrate exactly?
- Which points are used in the simple Simpson's rule on \([a,b]\)?
- Which weights appear in the simple Simpson's rule before the factor \(\frac{h}{3}\)?
- Which derivative appears in the error term of Simpson's rule?
- Apply the simple Simpson's rule to \(\int_0^2 x^2\,dx\). What is the result?
- Using the simple Simpson's rule, what is the approximate value of \(\int_0^1 e^x\,dx\)?
- With the composite Simpson's rule and \(n=4\) on \([0,4]\), what is the width \(h\) of each subinterval?
- What is the value of the composite Simpson's rule with \(n=2\) for \(\int_0^2 x^3\,dx\)?
- Apply the composite Simpson's rule with \(n=4\) to \(\int_0^4 x^2\,dx\). What value do you get?
What comes next
References
- Richard L. Burden, J. Douglas Faires, Annette M. Burden, Numerical Analysis, 10th edition, Cengage Learning, 2016.
- Lloyd N. Trefethen, David Bau III, Numerical Linear Algebra, 1st edition, SIAM, 1997.