The most basic of these rules, called Simpson's 1/3 rule, or just Simpson's rule, reads
If the 1/3 rule is applied to n equal subdivisions of the integration range [a,b], one obtains the composite Simpson's 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 requests one more function evaluation inside the integration range, and is exact if f is a polynomial up to cubic degree.
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 (ship stability).
Simpson's 1/3 rule
One derivation replaces the integrand by the quadratic polynomial (i.e. parabola) which takes the same values as at the end points and and the midpoint . One can use Lagrange polynomial interpolation to find an expression for this polynomial,
Averaging the midpoint and the trapezoidal rules
Another derivation constructs Simpson's rule from two simpler approximations: the midpoint 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.
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.
The error in approximating an integral by Simpson's rule for is
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.
If the second derivative exists and is convex in the interval :
Composite Simpson's 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, 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 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 into sub-intervals, with an even number. Then, the composite Simpson's rule is given by
where for with ; in particular, and . 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 (in absolute value) 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.
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. Simpson's 3/8 rule is as follows:
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 nodes 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 remainding subintervals without changing the order of the error term (conversely, the 3/8 rule can be used with a composite 1/3 rule for odd-numbered subintervals).
Alternative extended Simpson's rule
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:
The formula above is obtained by combining the original composite Simpson's rule with the one consisting of 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 rules in the case of narrow peaks
In the task of estimation of full area of narrow peak-like functions, Simpson's rules are much less efficient than trapezoidal rule. Namely, composite Simpson's 1/3 rule requires 1.8 times more points to achieve the same accuracy as trapezoidal rule. Composite Simpson's 3/8 rule is even less accurate. Integral by Simpson's 1/3 rule can be represented as a sum of 2/3 of integral by trapezoidal rule with step h and 1/3 of integral by rectangle rule with step 2h. Averaging of Simpson's 1/3 rule composite sums with properly shifted frames produces the following rules:
where two points outside of the integrated region are exploited and
These rules are very much similar to Press's alternative extended Simpson's rule. Coefficients within the major part of the region being integrated equal one, differences are only at the edges. These three rules can be associated with Euler-MacLaurin formula with the first derivative term and named Euler-MacLaurin integration rules. They differ only in how the first derivative at the region end is calculated.
Composite Simpson's rule for irregularly spaced data
For some applications, the integration interval needs to be divided into uneven intervals – perhaps due to uneven sampling of data, or missing or corrupted data points. Suppose we divide the interval into even number of subintervals of widths . Then the composite Simpson's rule is given by
where are the function values at the th sampling point on the interval .
In case of odd number of subintervals, the above formula are used up to the second to last interval, and the last interval is handled separately by adding the following to the result:
|Example implementation in Python|
from collections.abc import Sequence def simpson_nonuniform(x: Sequence[float], f: Sequence[float]) -> float: """ Simpson rule for irregularly spaced data. :param x: Sampling points for the function values :param f: Function values at the sampling points :return: approximation for the integral See ``scipy.integrate.simpson`` and the underlying ``_basic_simpson`` for a more performant implementation utilizing numpy's broadcast. """ N = len(x) - 1 h = [x[i + 1] - x[i] for i in range(0, N)] assert N > 0 result = 0.0 for i in range(1, N, 2): h0, h1 = h[i - 1], h[i] hph, hdh, hmh = h1 + h0, h1 / h0, h1 * h0 result += (hph / 6) * ( (2 - hdh) * f[i - 1] + (hph**2 / hmh) * f[i] + (2 - 1 / hdh) * f[i + 1] ) if N % 2 == 1: h0, h1 = h[N - 2], h[N - 1] result += f[N] * (2 * h1 ** 2 + 3 * h0 * h1) / (6 * (h0 + h1)) result += f[N - 1] * (h1 ** 2 + 3 * h1 * h0) / (6 * h0) result -= f[N - 2] * h1 ** 3 / (6 * h0 * (h0 + h1)) return result
- 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
- Matthews (2004)
- Press (1989), p. 122
- Kalambet, Yuri; Kozmin, Yuri; Samokhin, Andrey (2018). "Comparison of integration rules in the case of very narrow chromatographic peaks". Chemometrics and Intelligent Laboratory Systems. 179: 22–30. doi:10.1016/j.chemolab.2018.06.001. ISSN 0169-7439.
- Kylänpää, Ilkka (2019). Computational Physics course. Tampere University.
- Shklov, N. (December 1960). "Simpson's Rule for Unequally Spaced Ordinates". The American Mathematical Monthly. 67 (10): 1022. doi:10.2307/2309244.
- ; might have
- Atkinson, Kendall E. (1989). An Introduction to Numerical Analysis (2nd ed.). John Wiley & Sons. ISBN 0-471-50023-2.
- Burden, Richard L.; 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. Archived from the original on 4 December 2008. Retrieved 11 November 2008.
- Press, William H.; Flannery, Brian P.; Vetterling, William T.; Teukolsky, Saul A. (1989). Numerical Recipes in Pascal: The Art of Scientific Computing. Cambridge University Press. ISBN 0-521-37516-9.
- Süli, Endre; Mayers, David (2003). An Introduction to Numerical Analysis. Cambridge University Press. ISBN 0-521-00794-1.
- Kaw, Autar; Kalu, Egwu; Nguyen, Duc (2008). "Numerical Methods with Applications".
- Weisstein, Eric W. (2010). "Newton-Cotes Formulas". MathWorld--A Wolframtite Web Resource. MathWorld. Retrieved 2 August 2010.
- "Simpson formula", Encyclopedia of Mathematics, EMS Press, 2001 
- Weisstein, Eric W. "Simpson's Rule". MathWorld.
- 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