Simpson's Rule: Derivation
Simpson's Rule: Derivation
Simpson's rule can be derived by approximating the integrand f (x) (in blue) by the quadratic interpolant P (x) (in red).
In numerical analysis, Simpson's rule is a method for numerical integration, the numerical approximation of definite integrals. Specifically, it is the following approximation:
Simpson's rule also corresponds to the 3-point Newton-Cotes quadrature rule. The method is credited to the mathematician Thomas Simpson (17201761) of Leicestershire, England. Kepler used similar formulas over 100 years prior and in German the method is sometimes called Keplersche Fassregel for this reason. Simpson's rule is a staple of scientific data analysis and engineering. It is widely used, for example, by Naval architects to calculate the capacity of a ship orlifeboat.[1]
[edit]Derivation
Simpson's rule can be derived in various ways.
[edit]Quadratic
interpolation
One derivation replaces the integrand f(x) by the quadratic polynomial P(x) which takes the same values as f(x) at the end points a and b and the midpoint m = (a + b) / 2. One can use Lagrange polynomial interpolation to find an expression for this polynomial,
[2]
This calculation can be carried out more easily if one first observes that (by scaling) there is no loss of generality in assuming that a
= 1 and b = 1.
[edit]Averaging
Another derivation constructs Simpson's rule from two simpler approximations: the midpoint rule
respectively. It follows that the leading error term vanishes if we take the weighted average
This weighted average is exactly Simpson's rule. Using another approximation (for example, the trapezoidal rule with twice as many points), it is possible to take a suitable weighted average and eliminate another error term. This is Romberg's method.
[edit]Undetermined
coefficients
The coefficients , and can be fixed by requiring that this approximation be exact for all quadratic polynomials. This yields Simpson's rule.
[edit]Error
The error in approximating an integral by Simpson's rule is
where is some number between a and b.[3] The error is asymptotically proportional to (b
Simpson's rule gains an extra order because the points at which the integrand is evaluated are distributed symmetrically in the interval [a, b]. Simpson's rule provides exact results for any polynomial of degree three or less, since the error term involves the fourth derivative of f.
[edit]Composite
Simpson's rule
If the interval of integration [a,b] is in some sense "small", then Simpson's rule will provide an adequate approximation to the exact integral. By small, what we really mean is that the function being integrated is relatively smooth over the interval
[a,b]. 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 it 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 [a,b] into a number of 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 rule. Suppose that the interval [a,b] is split up in n subintervals, with n an even number. Then, the composite Simpson's rule is given by
where xj
= a + jh for j = 0,1,...,n 1,n with h = (b a) / n; = a and xn = b. The above formula can also
in particular, x0 be written as
The error committed by the composite Simpson's rule is bounded (in absolute value) by
= (b a)
/ n.
[4]
This formulation splits the interval [a,b] 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.
[edit]Alternative
[edit]Simpson's
3/8 rule
Simpson's 3/8 rule is another method for numerical integration proposed by Thomas Simpson. It is based upon a cubic interpolation rather than a quadratic interpolation. Simpson's 3/8 rule is as follows:
where is some number between a and b. 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.[6] Simpson's 3/8 rule is used by Naval architects to calculate a merchant cargo ship's lifeboat capacity.
[edit]Sample
implementation
An implementation of the composite Simpson's rule in pylab: def simpson(f, a, b, n): """f=function, a=initial value, b=end value, n=number of double intervals of size 2h""" n *= 2 h = (b - a) / n; S = f(a) for i in range(1, n, 2): x = a + h * i S += 4 * f(x) for i in range(2, n-1, 2): x = a + h * i S += 2 * f(x) S += f(b) F = h * S / 3 return F