Simpson's rule
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 (1710–1761) 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 numerically integrate hull offsets and cross-sectional areas to determine volumes and centroids of ships or lifeboats.[1]
Contents |
Derivation [edit]
Simpson's rule can be derived in various ways.
Quadratic interpolation [edit]
One derivation replaces the integrand
by the quadratic polynomial
which takes the same values as
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,
An easy (albeit tedious) calculation shows that
This calculation can be carried out more easily if one first observes that (by scaling) there is no loss of generality in assuming that
and
.
Averaging the midpoint and the trapezoidal rules [edit]
Another derivation constructs Simpson's rule from two simpler approximations: the midpoint rule
and the trapezoidal rule
The errors in these approximations are
respectively, 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 for the errors of the midpoint and trapezoidal rule 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.
Undetermined coefficients [edit]
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.
Error [edit]
The error in approximating an integral by Simpson's rule is
where
is some number between
and
.[3]
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 [a, b].
Since the error term is proportional to the fourth derivative of f at
, this shows that Simpson's rule provides exact results for any polynomial f of degree three or less, since the fourth derivative of such a polynomial is zero at all points.
Composite Simpson's rule [edit]
If the interval of integration
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
. 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
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
is split up in
subintervals, with
an even number. Then, the composite Simpson's rule is given by
where
for
with
; in particular,
and
. The above formula can also be written as
The error committed by the composite Simpson's rule is bounded (in absolute value) by
where
is the "step length", given by
[4]
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.
Alternative extended Simpson's rule [edit]
This is another formulation of a composite Simpson's rule: instead of applying Simpson's rule to disjoint segments of the integral to be approximated, Simpson's rule is applied to overlapping segments, yielding:[5]
The formula above is obtained by combining the original composite Simpson's rule with the one consisting in using Simpson's 3/8 rule in the extreme subintervals and the standard 3-point rule in the remaining subintervals. The result is then obtained by taking the mean of the two formulas.
Simpson's 3/8 rule [edit]
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 b - a = 3h. 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.[6]
A further generalization of this concept for interpolation with arbitrary degree polynomials are the Newton–Cotes formulas.
Simpson's 3/8 rule (for n point) [edit]
h=(b-a)/n
x_i = a + i*h
Sample Implementations [edit]
An implementation of the composite Simpson's rule in Python 2:
#!/usr/bin/env python2 from __future__ import division def simpson(f, a, b, n): """Approximates the definite integral of f from a to b by the composite Simpson's rule, using n subintervals""" h = (b - a) / n s = f(a) + f(b) for i in range(1, n, 2): s += 4 * f(a + i * h) for i in range(2, n-1, 2): s += 2 * f(a + i * h) return s * h / 3 print simpson(lambda x:x**9, 0.0, 10.0, 100000) # displays 1000000000.0
An implementation of the composite Simpson's rule in Matlab R2011b:
function [approx h feval] = cs(f,a,b,n) %% f is the given function to evaluate %% a is the starting point on the interval %% b is the ending point on the interval %% n is the number of intervals to segment %% feval is the number of times that the given function is evaluated %% approx is the approximation yielded by composite Simpson's method % via the given function %% h is the h that is generated by the given inputs feval = 0; h = (b - a) / n; sum = f(a) + f(b); feval = feval + 2; for i = 1:2:n sum = sum + 4 * f(a + i * h); feval= feval + 1; end for i = 2:2:n-1 sum = sum + 2*f(a + i *h); feval = feval + 1; end approx = sum*h/3; end
See also [edit]
Notes [edit]
- ^ McCall Pate (1918). The naval artificer's manual: (The naval artificer's handbook revised) text, questions and general information for deck. United States. Bureau of Reconstruction and Repair. p. 198.
- ^ Atkinson, p. 256; Süli and Mayers, §7.2
- ^ Atkinson, equation (5.1.15); Süli and Mayers, Theorem 7.2
- ^ Atkinson, pp. 257+258; Süli and Mayers, §7.5
- ^ Press (1989), p. 122
- ^ Matthews (2004)
References [edit]
- Atkinson, Kendall E. (1989). An Introduction to Numerical Analysis (2nd ed.). John Wiley & Sons. ISBN 0-471-50023-2.
- Burden, Richard L. and Faires, J. Douglas (2000). Numerical Analysis (7th ed.). Brooks/Cole. ISBN 0-534-38216-9.
- Matthews, John H. (2004). "Simpson's 3/8 Rule for Numerical Integration". Numerical Analysis - Numerical Methods Project. California State University, Fullerton. Retrieved 11 November 2008.
- Press, William H., Brian P. Flannery, William T. Vetterling, and Saul A. Teukolsky (1989). Numerical Recipes in Pascal: The Art of Scientific Computing. Cambridge University Press. ISBN 0-521-37516-9.
- Süli, Endre and Mayers, David (2003). An Introduction to Numerical Analysis. Cambridge University Press. ISBN 0-521-81026-4 (hardback), ISBN 0-521-00794-1 (paperback) Check
|isbn=value (help). - Kaw, Autar; Kalu, Egwu (2008). "Numerical Methods with Applications" (1st ed.). [1]. .
- Weisstein, Eric W. (2010). "Newton-Cotes Formulas". MathWorld--A Wolfram Web Resource. MathWorld. Retrieved 2 August 2010.
External links [edit]
- Hazewinkel, Michiel, ed. (2001), "Simpson formula", Encyclopedia of Mathematics, Springer, ISBN 978-1-55608-010-4
- Weisstein, Eric W., "Simpson's Rule", MathWorld.
- Simpson's Rule for Numerical Integration
- Application of Simpson's Rule — Earthwork Excavation (Note: The formula described in this page is correct but there are errors in the calculation which should give a result of 569m3 and not 623m3 as stated)
- Simpson's 1/3rd rule of integration — Notes, PPT, Mathcad, Matlab, Mathematica, Maple at Numerical Methods for STEM undergraduate
- A detailed description of a computer implementation is described by Dorai Sitaram in Teach Yourself Scheme in Fixnum Days, Appendix C
- C Language Program to Implement Simpson's Rule
This article incorporates material from Code for Simpson's rule on PlanetMath, which is licensed under the Creative Commons Attribution/Share-Alike License.
![\int_{a}^{b} f(x) \, dx \approx \frac{b-a}{6}\left[f(a) + 4f\left(\frac{a+b}{2}\right)+f(b)\right].](http://upload.wikimedia.org/math/c/d/1/cd18b1d075e9c7d4e65314c8e95ccb45.png)

![\int_{a}^{b} P(x) \, dx =\frac{b-a}{6}\left[f(a) + 4f\left(\frac{a+b}{2}\right)+f(b)\right].](http://upload.wikimedia.org/math/1/1/5/115da26758258fe2602edd2aa726f609.png)






![\int_a^b f(x) \, dx\approx
\frac{h}{3}\bigg[f(x_0)+2\sum_{j=1}^{n/2-1}f(x_{2j})+
4\sum_{j=1}^{n/2}f(x_{2j-1})+f(x_n)
\bigg],](http://upload.wikimedia.org/math/a/c/2/ac281e21c702c7a01b4270ada92baa27.png)
![\int_a^b f(x) \, dx\approx
\frac{h}{3}\bigg[f(x_0)+4f(x_1)+2f(x_2)+4f(x_3)+2f(x_4)+\cdots+4f(x_{n-1})+f(x_n)\bigg].](http://upload.wikimedia.org/math/f/c/6/fc61f35f7389b33860f375d899c7d16b.png)
![\frac{h^4}{180}(b-a) \max_{\xi\in[a,b]} |f^{(4)}(\xi)|,](http://upload.wikimedia.org/math/0/9/6/096a8751090c5beef2e8ef0fa7fa1c2b.png)
![\int_a^b f(x) \, dx\approx
\frac{h}{48}\bigg[17f(x_0)+59f(x_1)+43f(x_2)+49f(x_3)+48 \sum_{i=4}^{n-4} f(x_i)+49f(x_{n-3})+43f(x_{n-2})+59f(x_{n-1})+17f(x_n)\bigg].](http://upload.wikimedia.org/math/5/3/2/532763cbfedbc270226ae280a9310a6f.png)
![\int_{a}^{b} f(x) \, dx \approx \frac{3h}{8}\left[f(a) + 3f\left(\frac{2a+b}{3}\right) + 3f\left(\frac{a+2b}{3}\right) + f(b)\right]
= \frac{(b-a)}{8}\left[f(a) + 3f\left(\frac{2a+b}{3}\right) + 3f\left(\frac{a+2b}{3}\right) + f(b)\right]\, ,](http://upload.wikimedia.org/math/2/2/8/2286f6685492d4b89e01e1b6ae7ff530.png)

![\int_{a}^{b} f(x) \, dx \approx \frac{3h}{8}\left[f(x_0) + 3f(x_1) + 3f(x_2)
+ 2f(x_3) + 3f(x_4) + 3f(x_5) + 2f(x_6) + ... + f(x_n)\right] ,](http://upload.wikimedia.org/math/5/3/5/535f0cd218424d80fc9d0ff2a54f5a36.png)