Simpson’s Rule
Contents
Simpson’s Rule#
A way to interpret the trapezoidal method is that we approximate the integrand curve as a straight line, and then integrate that directly. The Simpson’s method does something similar, but instead of only using the integrand values at the boundaries it uses a third point (the midpoint) to approximate the integrand as a parabola.
The method approximates the integral as:
with the derivation of this in the following section.
Derivation#
Approximating \(f(x)\) as a Quadratic Polynomial#
In order to approximate \(f(x)\) as a quadratic polynomial we can use a second order Lagrange polynomial. We construct this polynomial by using 3 data points \((a, f(a))\), \((m, f(m))\) and \((b, f(b))\).
If we use the midpoint of \([a, b]\) for \(m\), i.e:
then we have
and the Lagrange polynomial becomes:
Integrating \(L(x)\)#
Now, we wish to approximate the integral of \(f(x)\) as the integral of our Lagrange polynomial:
illustrated in the figure below:
by substituting the variable:
into the integral of \(L(x)\) we find that:
thus, we approximate the integral of \(f(x)\) as:
Alternative Derivation#
Another way to see the Simpson’s rule is as a weighted average of the midpoint and trapezoidal rules:
2/3 midpoint + 1/3 trapezoidal
Mathematically:
Composite Simpson’s Rule#
As before we can improve the accuracy of our solution by subdividing the interval and calculating the integral using Simpson’s rule for each subinterval.
The composite Simpson’s rule is given by:
If we use equal sized subintervals, then we have that:
taking this into account and the values of \(f(x_i)\) which are repeated in the sum, the composite Simpson’s rule can be simplified to:
Assuming that \(0 < \tfrac{b - a}{6 n} < 1\), then the error for this method is \(O\left(\tfrac{1}{n}^4\right)\) [IntSimp1]
Composite Simpson’s Rule with a Discrete Data Set#
Again, consider the data set \((x_i, y_i)\) for \(i = 0, \dots, n\), where
Approximating the integral of the data using Simpson’s rule is a lot less straight forward than the Midpoint and Trapezoidal rule as we can’t calculate \(f\left((x_{i -1} + x_i)/2\right)\) directly, and the function values at the boundaries of the intervals are also required.
If the \(x_i\) values are uniformly spaced (with \(x_i - x_{i-1} = \Delta x\)) and there is an odd number of data points, we can pair up the intervals between the points. Treating each pair of subintervals as a single subinterval, we can use the middle \(x\) values as the midpoints. In other words, for even \(i= 2j\), the \(x_{2j}\) are used as the boundaries of the sub-intervals; for odd \(i = 2k -1\), the \(x_{2k-1}\) are used as the midpoints of the subinterval. Thus the integral is approximated as:
Note that
as each subinterval is made up of two intervals of length \(\Delta x\) each.
References#
- IntSimp1
James F. Epperson. An Introduction to Numerical Methods and Analysis. John Wiley & Sons, Inc., Hoboken, New Jersey, second edition edition, 2013.