Simpson's rule


In numerical integration, Simpson's rules are several approximations for definite integrals, named after Thomas Simpson.
The most basic of these rules, called Simpson's 1/3 rule, or just Simpson's rule, reads
In German and some other languages, it is named after Johannes Kepler, who derived it in 1615 after seeing it used for wine barrels. The approximate equality in the rule becomes exact if is a polynomial up to and including 3rd degree.
If the 1/3 rule is applied to n equal subdivisions of the integration range , one obtains the composite Simpson's 1/3 rule. Points inside the integration range are given alternating weights 4/3 and 2/3.
Simpson's 3/8 rule, also called Simpson's second rule, requires one more function evaluation inside the integration range and gives lower error bounds, but does not improve the order of the error.
If the 3/8 rule is applied to n equal subdivisions of the integration range , one obtains the composite Simpson's 3/8 rule.
Simpson's 1/3 and 3/8 rules are two special cases of closed Newton–Cotes formulas.
In naval architecture and ship stability estimation, there also exists Simpson's third rule, which has no special importance in general numerical analysis, see Simpson's rules.

Simpson's 1/3 rule

Simpson's 1/3 rule, also simply called Simpson's rule, is a method for numerical integration proposed by Thomas Simpson. It is based upon a quadratic interpolation and is the composite Simpson's 1/3 rule evaluated for. Simpson's 1/3 rule is as follows:
where is the step size for.
The error in approximating an integral by Simpson's rule for is
where is some number between and.
The error is asymptotically proportional to. However, the above derivations suggest an error proportional to. Simpson's rule gains an extra order because the points at which the integrand is evaluated are distributed symmetrically in the interval.
Since the error term is proportional to the fourth derivative of at, this shows that Simpson's rule provides exact results for any polynomial of degree three or less, since the fourth derivative of such a polynomial is zero at all points. Another way to see this result is to note that any interpolating cubic polynomial can be expressed as the sum of the unique interpolating quadratic polynomial plus an arbitrarily scaled cubic polynomial that vanishes at all three points in the interval, and the integral of this second term vanishes because it is odd within the interval.
If the second derivative exists and is convex in the interval, then

Derivations

Quadratic interpolation

Consider finding the area under a general parabola between and for some positive number. The midpoint of this interval is therefore at.
The area under the parabola,, is therefore
Assuming the parabola has midpoint and endpoints and, substituting these three points into the parabola formula gives
Solving these gives
from the second equation, and
by adding the first and third equations. Substituting this into the expression for gives
Simpsons 1/3 rule approximates a definite integral over an interval by replacing the integrand with a parabola which interpolates the function at, and the midpoint of the interval, which gives
Because of the factor, Simpson's rule is also referred to as "Simpson's 1/3 rule".

Averaging the midpoint and the trapezoidal rules

Another derivation constructs Simpson's rule from two simpler approximations. For functions that behave like polynomials over the interval, the midpoint rule says
and the trapezoidal rule says
where denotes a term asymptotically proportional to. The two terms are not equal; see Big O notation for more details. It follows from the above formulas that the leading error term vanishes if we take the weighted average
This weighted average is exactly Simpson's rule.
Using another approximation, it is possible to take a suitable weighted average and eliminate another error term. This is Romberg's method.

Undetermined coefficients

The third derivation starts from the ansatz
The coefficients, and can be fixed by requiring that this approximation be exact for all quadratic polynomials. This yields Simpson's rule.

Composite Simpson's 1/3 rule

If the interval of integration is in some sense "small", then Simpson's rule with subintervals will provide an adequate approximation to the exact integral. By "small" we mean that the function being integrated is relatively smooth over the interval. For such a function, a smooth quadratic interpolant like the one used in Simpson's rule will give good results.
However, it is often the case that the function we are trying to integrate is not smooth over the interval. Typically, this means that either the function is highly oscillatory or lacks derivatives at certain points. In these cases, Simpson's rule may give very poor results. One common way of handling this problem is by breaking up the interval into small subintervals. Simpson's rule is then applied to each subinterval, with the results being summed to produce an approximation for the integral over the entire interval. This sort of approach is termed the composite Simpson's 1/3 rule, or just composite Simpson's rule.
Suppose that the interval is split up into subintervals, with an even number. Then, the composite Simpson's rule is given by
Dividing the interval into subintervals of length and introducing the points for , we have
This composite rule with corresponds with the regular Simpson's rule of the preceding section.
The error committed by the composite Simpson's rule is
where is some number between and, and is the "step length". The error is bounded by
This formulation splits the interval in subintervals of equal length. In practice, it is often advantageous to use subintervals of different lengths and concentrate the efforts on the places where the integrand is less well-behaved. This leads to the adaptive Simpson's method.

Examples

Approximating the natural logarithm of 2

Since
approximations of can be generated by approximating this integral. Applying Composite Simpson's 1/3 rule with intervals gives
which has a relative error of about.

An application to statistics

In statistics, when data tends around a central value with no left or right bias, it's said to be normally distributed. In the case where the mean is zero and the standard deviation is 1, the curve is said to follow the standard normal distribution. The equation of this distribution is
By the 68–95–99.7 rule, approximately 68.27% of values are within a single standard deviation of the mean, so
This result can be verified with Composite Simpson's 1/3 rule - applying the rule with intervals gives
as expected.
Similarly, the 68–95–99.7 rule says approximately 95.45% of values are within two standard deviations of the mean, so
As before, this result can be verified with Composite Simpson's 1/3 rule - applying the rule with intervals gives
which has a relative error of about. The interval of integration can be shortened by noting that the integrand is an even function, so
Once again, applying Composite Simpson's 1/3 rule with intervals gives
which has an improved relative error of about but with the same number of intervals.

Approximating π

Since
this can be rearranged to give
Therefore, approximations of can be generated by approximating this integral. Applying Composite Simpson's 1/3 rule with intervals gives
which remarkably only has a relative error of about.

Determining the number of intervals for a desired accuracy

Suppose we wish to determine the number of intervals required to approximate with an absolute error of less than. The error term in Composite Simpson's 1/3 rule is
for some between and. Since the absolute error is to be less than, we can calculate
which gives
so will generate the required accuracy.
For comparison purposes, suppose we wish to be assured of this degree of accuracy using the Composite Trapezoidal Rule. In this case, the error term is
for some between and. Since the absolute error is to be less than, we can calculate
which gives
so will guarantee the required accuracy. This is significantly more calculations compared to Composite Simpson's 1/3 rule.

Simpson's 3/8 rule

Simpson's 3/8 rule, also called Simpson's second rule, is another method for numerical integration proposed by Thomas Simpson. It is based upon a cubic interpolation rather than a quadratic interpolation.
Consider finding the area,, under a general cubic between and for some positive number. This is given by
Assuming four equally spaced points over the interval of integration are,, and, substituting these four points into the cubic formula gives
Adding the first and third equation gives
and adding the fourth equation to two times the second equation gives
We now have
Simpsons 3/8 rule approximates a definite integral over an interval by replacing the integrand with a cubic which interpolates the function at four equally spaced points,,, and, where is the step size. This gives
The error of this method is
where is some number between and. Thus, the 3/8 rule is about twice as accurate as the standard method, but it uses one more function value. A composite 3/8 rule also exists, similarly as above.
A further generalization of this concept for interpolation with arbitrary-degree polynomials are the Newton–Cotes formulas.

Composite Simpson's 3/8 rule

Dividing the interval into subintervals of length and introducing the points for , we have
While the remainder for the rule is shown as
we can only use this if is a multiple of three. The 1/3 rule can be used for the remaining subintervals without changing the order of the error term.