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 n = 2. Simpson's 1/3 rule is as follows: \begin{align} \int_a^b f(x)\, dx &\approx \frac{b - a}{6} \left[f(a) + 4f\left(\frac{a + b}{2}\right) + f(b)\right]\\ &= \frac{1}{3} h\left[f(a) + 4f\left(a + h\right) + f(b)\right], \end{align} where h = (b - a)/n is the step size for n = 2. The error in approximating an integral by Simpson's rule for n = 2 is -\frac{1}{90} h^5f^{(4)}(\xi) = -\frac{(b - a)^5}{2880} f^{(4)}(\xi), where \xi (the
Greek letter xi) is some number between a and b. The error is asymptotically proportional to (b - a)^5. However, the above derivations suggest an error proportional to (b - a)^4. 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 \xi, 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. 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 f'' exists and is
convex in the interval (a,\ b), then (b - a) f\left(\frac{a + b}{2}\right) + \frac{1}{3} \left(\frac{b - a}{2}\right)^3 f''\left(\frac{a + b}{2}\right) \leq \int_a^b f(x)\, dx \leq \frac{b - a}{6} \left[f(a) + 4f\left(\frac{a + b}{2}\right) + f(b)\right].
Derivations Quadratic interpolation Consider finding the area under a general parabola y = ax^2 + bx + c between x=-h and x=h for some positive number h. The midpoint of this interval is therefore at x=0. The area under the parabola, A, is therefore \begin{align} A = \int_{-h}^{h} ax^2 + bx + c \, dx & = \left[\frac{ax^3}{3} + \frac{bx^2}{2} + cx \right]_{x=-h}^{x=h} \\ &= \left( \frac{ah^3}{3} + \frac{bh^2}{2} + ch \right) - \left(-\frac{ah^3}{3} + \frac{bh^2}{2} -ch \right) \\ &= \frac{2ah^3}{3} + 2ch \\ &= \frac{h}{3} \left(2ah^2 + 6c \right). \end{align} Assuming the parabola has midpoint (0, y_{1}) and endpoints (-h, y_{0}) and (h, y_{2}), substituting these three points into the parabola formula gives y_{0} = ah^2 - bh + c y_{1} = c y_{2} = ah^2 + bh + c. Solving these gives c = y_{1} from the second equation, and 2ah^2 = y_{0} - 2y_{1} + y_{2} by adding the first and third equations. Substituting this into the expression for A gives \begin{align} A &= \frac{h}{3} \left(2ah^2 + 6c \right) \\ &= \frac{h}{3} \left( y_{0} - 2y_{1} + y_{2} + 6y_{1} \right) \\ &= \frac{h}{3} \left( y_{0} + 4y_{1} + y_{2} \right). \end{align} Simpsons 1/3 rule approximates a definite integral over an interval by replacing the integrand with a parabola which interpolates the function at x=a, x=b and the midpoint of the interval, which gives \int_a^b f(x)\, dx \approx A = \frac{1}{3}h\left[f(a) + 4f(a + h ) + f(b)\right]. Because of the 1/3 factor, Simpson's rule is also referred to as "Simpson's 1/3 rule" (see below for generalization).
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 [a,b], the
midpoint rule says M = (b - a)f\left(\frac{a + b}{2}\right) = \int_{a}^{b} f(x) dx - \frac{1}{24} (b - a)^3 f''(a) + O\big((b - a)^4\big) and the
trapezoidal rule says T = (b - a)\left(\frac{f(a) + f(b)}{2}\right) = \int_{a}^{b} f(x) dx +\frac{1}{12} (b - a)^3 f''(a) + O\big((b - a)^4\big), where O\big((b - a)^4\big) denotes a term asymptotically proportional to (b - a)^4. The two O\big((b - a)^4\big) 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 \frac{2M + T}{3} = \int_{a}^{b} f(x) \, dx + O((b-a)^4). 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 The third derivation starts from the
ansatz \frac{1}{b - a} \int_a^b f(x)\, dx \approx \alpha f(a) + \beta f\left(\frac{a + b}{2}\right) + \gamma f(b). The coefficients , and can be fixed by requiring that this approximation be exact for all quadratic polynomials. This yields Simpson's rule. (This derivation is essentially a less rigorous version of the quadratic interpolation derivation, where one saves significant calculation effort by guessing the correct functional form.)
Composite Simpson's 1/3 rule If the interval of integration [a, b] is in some sense "small", then Simpson's rule with n = 2 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 [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 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 n > 2 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 [a, b] is split up into n subintervals, with n an
even number. Then, the composite Simpson's rule is given by Dividing the interval [a, b] into n subintervals of length h = (b - a)/n and introducing the points x_i = a + ih for 0 \leq i \leq n (in particular, x_0 = a and x_n = b), we have \begin{align} \int_a^b f(x)\, dx &\approx \frac{1}{3} h\sum_{i = 1}^{n/2}\big[f(x_{2i - 2}) + 4f(x_{2i - 1}) + f(x_{2i})\big]\\ &= \frac{1}{3} h\big[f(x_0) + 4f(x_1) + 2f(x_2) + 4f(x_3) + 2f(x_4) + \dots + 2f(x_{n - 2}) + 4f(x_{n - 1}) + f(x_n)\big]\\ &= \frac{1}{3} h\left[f(x_0) + 4\sum_{i = 1}^{n/2} f(x_{2i - 1}) + 2\sum_{i = 1}^{n/2 - 1} f(x_{2i}) + f(x_n)\right]. \end{align} This composite rule with n = 2 corresponds with the regular Simpson's rule of the preceding section. The error committed by the composite Simpson's rule is -\frac{1}{180} h^4(b - a)f^{(4)}(\xi), where \xi is some number between a and b, and h = (b - a)/n is the "step length". The error is bounded (in
absolute value) by \frac{1}{180} h^4(b - a) \max_{\xi \in [a, b]} \left|f^{(4)}(\xi)\right|. 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.
Examples Approximating the natural logarithm of 2 Since \int_{1}^{2} \frac{1}{x} \,dx = \ln(2) - \ln(1) = \ln(2), approximations of \ln(2) can be generated by approximating this integral. Applying Composite Simpson's 1/3 rule with n=6 intervals gives \begin{align} \ln(2) = \int_{1}^{2} \frac{1}{x} \,dx &\approx \frac{1}{18} \left(\ 1 + \frac{24}{7} + \frac{3}{2} + \frac{8}{3} + \frac{6}{5} + \frac{24}{11} + \frac{1}{2} \right) \\ &\approx 0.69316, \end{align} which has a relative error of about 0.003%.
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 (or
standard Gaussian) distribution. The equation of this distribution is f(x) = \frac{1}{\sqrt{2 \pi}} \exp \left( \frac{-x^{2}}{2} \right). By the
68–95–99.7 rule, approximately 68.27% of values are within a single standard deviation of the mean, so \int_{-1}^1 \frac{1}{\sqrt{2 \pi}} \exp \left( \frac{-x^{2}}{2} \right) dx \approx 0.6827. This result can be verified with Composite Simpson's 1/3 rule - applying the rule with n=6 intervals gives \begin{align} \int_{-1}^{1} \frac{1}{\sqrt{2 \pi}} \exp \left( \frac{-x^{2}}{2} \right) \,dx &\approx \frac{1}{\sqrt{2 \pi}} \times \frac{1}{9} \left(\ \frac{1}{e^{\frac{1}{2}}} + \frac{4}{e^{\frac{2}{9}}} + \frac{2}{e^{\frac{1}{18}}} + \frac{4}{1} + \frac{2}{e^{\frac{1}{18}}} + \frac{4}{e^{\frac{2}{9}}} + \frac{1}{e^{\frac{1}{2}}} \right) \\ &\approx \frac{1}{\sqrt{2 \pi}} \times 1.71142 \\ &\approx 0.6827, \end{align} as expected. Similarly, the 68–95–99.7 rule says approximately 95.45% of values are within two standard deviations of the mean, so \int_{-2}^2 \frac{1}{\sqrt{2 \pi}} \exp \left( \frac{-x^{2}}{2} \right) dx \approx 0.9545. As before, this result can be verified with Composite Simpson's 1/3 rule - applying the rule with n=6 intervals gives \begin{align} \int_{-2}^{2} \frac{1}{\sqrt{2 \pi}} \exp \left( \frac{-x^{2}}{2} \right) \,dx &\approx \frac{1}{\sqrt{2 \pi}} \times \frac{2}{9} \left(\ \frac{1}{e^{2}} + \frac{4}{e^{\frac{8}{9}}} + \frac{2}{e^{\frac{2}{9}}} + \frac{4}{1} + \frac{2}{e^{\frac{2}{9}}} + \frac{4}{e^{\frac{8}{9}}} + \frac{1}{e^{2}} \right) \\ &\approx \frac{1}{\sqrt{2 \pi}} \times 2.39167 \\ &\approx 0.9541, \end{align} which has a
relative error of about 0.0419%. The interval of integration can be shortened (thereby reducing
discretization error) by noting that the integrand is an
even function, so \int_{-2}^{2} \frac{1}{\sqrt{2 \pi}} \exp \left( \frac{-x^{2}}{2} \right) \,dx = 2 \int_{0}^{2} \frac{1}{\sqrt{2 \pi}} \exp \left( \frac{-x^{2}}{2} \right) \,dx. Once again, applying Composite Simpson's 1/3 rule with n=6 intervals gives \begin{align} 2\int_{0}^{2} \frac{1}{\sqrt{2 \pi}} \exp \left( \frac{-x^{2}}{2} \right) \,dx &\approx \frac{2}{\sqrt{2 \pi}} \times \frac{1}{9} \left(\ 1 + \frac{4}{e^{\frac{1}{18}}} + \frac{2}{e^{\frac{2}{9}}} + \frac{4}{e^{\frac{1}{2}}} + \frac{2}{e^{\frac{8}{9}}} + \frac{4}{e^{\frac{25}{18}}} + \frac{1}{e^{2}} \right) \\ &\approx \frac{2}{\sqrt{2 \pi}} \times 1.19626 \\ &\approx 0.9544, \end{align} which has an improved relative error of about 0.0104% but with the same number of intervals.
Approximating π Since \int_{0}^{1} \frac{1}{1 + x^{2}} \,dx = \arctan(1) - \arctan(0) = \frac{\pi}{4}, this can be rearranged to give \pi = 4 \int_{0}^{1} \frac{1}{1 + x^{2}} \,dx. Therefore, approximations of \pi can be generated by approximating this integral. Applying Composite Simpson's 1/3 rule with n=6 intervals gives \begin{align} \pi = 4 \int_{0}^{1} \frac{1}{1 + x^{2}} \,dx &\approx \frac{2}{9} \left(\ 1 + \frac{144}{37} + \frac{9}{5} + \frac{16}{5} + \frac{18}{13} + \frac{144}{61} + \frac{1}{2} \right) \\ &\approx 3.141591, \end{align} which remarkably only has a relative error of about 0.00002%.
Determining the number of intervals for a desired accuracy Suppose we wish to determine the number of intervals required to approximate \int_{0}^{\pi} \sin(x) \,dx with an absolute error of less than 0.00001. The error term in Composite Simpson's 1/3 rule is - \frac{\pi h^{4}}{180} \sin(\xi) for some \xi between 0 and \pi. Since the absolute error is to be less than 0.00001, we can calculate \left| \frac{\pi h^{4}}{180} \sin(\xi) \right| \le \frac{\pi h^{4}}{180} = \frac{\pi^{5}}{180n^{4}} which gives n > \sqrt[4]{\frac{\pi^{5}}{0.0018}} \approx 20.3, so n=22 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 - \frac{\pi h^{2}}{12} \sin(\xi) for some \xi between 0 and \pi. Since the absolute error is to be less than 0.00001, we can calculate \left| \frac{\pi h^{2}}{12} \sin(\xi) \right| \le \frac{\pi h^{2}}{12} = \frac{\pi^{3}}{12n^{2}} which gives n > \sqrt{\frac{\pi^{3}}{0.00012}} \approx 508.3, so n=509 will guarantee the required accuracy. This is significantly more calculations compared to Composite Simpson's 1/3 rule. == Simpson's 3/8 rule ==