Adaptive Simpson's method

1

Adaptive Simpson's method, also called adaptive Simpson's rule, is a method of numerical integration proposed by G.F. Kuncir in 1962. It is probably the first recursive adaptive algorithm for numerical integration to appear in print, although more modern adaptive methods based on Gauss–Kronrod quadrature and Clenshaw–Curtis quadrature are now generally preferred. Adaptive Simpson's method uses an estimate of the error we get from calculating a definite integral using Simpson's rule. If the error exceeds a user-specified tolerance, the algorithm calls for subdividing the interval of integration in two and applying adaptive Simpson's method to each subinterval in a recursive manner. The technique is usually much more efficient than composite Simpson's rule since it uses fewer function evaluations in places where the function is well-approximated by a cubic function. Simpson's rule is an interpolatory quadrature rule which is exact when the integrand is a polynomial of degree three or lower. Using Richardson extrapolation, the more accurate Simpson estimate for six function values is combined with the less accurate estimate S(a,b) for three function values by applying the correction. So, the obtained estimate is exact for polynomials of degree five or less.

Mathematical procedure

Defining terms

A criterion for determining when to stop subdividing an interval, suggested by J.N. Lyness, is where [a,b] is an interval with midpoint, while S(a,b),!, S(a,m),!, and S(m,b) given by Simpson's rule are the estimates of , , and respectively, and \varepsilon is the desired maximum error tolerance for the interval. Note,.

Procedural steps

To perform adaptive Simpson's method, do the following: if, add S(a,m) and S(m,b) to the sum of Simpson's rules which are used to approximate the integral, otherwise, perform the same operation with and instead of.

Numerical consideration

Some inputs will fail to converge in adaptive Simpson's method quickly, resulting in the tolerance underflowing and producing an infinite loop. Simple methods of guarding against this problem include adding a depth limitation (like in the C sample and in McKeeman), verifying that ε/2 ≠ ε in floating-point arithmetics, or both (like Kuncir). The interval size may also approach the local machine epsilon, giving a = b . Lyness's 1969 paper includes a "Modification 4" that addresses this problem in a more concrete way: [A, B] . Let the original tolerance be ε0 . [a, b] , define D(a, b) , the error estimate, as. Define E = 180 ε0 / (B - A) . The original termination criteria would then become D ≤ E . D(a, m) ≥ D(a, b) , either the round-off level have been reached or a zero for f(4) is found in the interval. A change in the tolerance ε0 to ε′0 is necessary. E' = 180 ε'0 / (B - A) is defined and initialized to E. D(a, m) . max(E, D(a, m)) . xi at which the E' is changed into an array of (xi, εi' ) pairs. The first entry should be (a, ε′0) . The epsilon-raising maneuver allows the routine to be used in a "best effort" mode: given a zero initial tolerance, the routine will try to get the most precise answer and return an actual error level.

Sample code implementations

A common implementation technique shown below is passing down f(a), f(b), f(m) along with the interval [a, b] . These values, used for evaluating S(a, b) at the parent level, will again be used for the subintervals. Doing so cuts down the cost of each recursive call from 6 to 2 evaluations of the input function. The size of the stack space used stays linear to the layer of recursions.

Python

Here is an implementation of adaptive Simpson's method in Python.

C

Here is an implementation of the adaptive Simpson's method in C99 that avoids redundant evaluations of f and quadrature computations. It includes all three "simple" defenses against numerical problems. This implementation has been incorporated into a C++ ray tracer intended for X-Ray Laser simulation at Oak Ridge National Laboratory, among other projects. The ORNL version has been enhanced with a call counter, templates for different datatypes, and wrappers for integrating over multiple dimensions.

Racket

Here is an implementation of the adaptive Simpson method in Racket with a behavioral software contract. The exported function computes the indeterminate integral for some given function f.

Related algorithms

n is the current level of recursion and S(2) is the more accurate estimate.

This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.

Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc.
Bliptext is not affiliated with or endorsed by Wikipedia or the Wikimedia Foundation.

Edit article