Rahul Sharma (Editor)

Adaptive Simpson's method

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

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.

Contents

A criterion for determining when to stop subdividing an interval, suggested by J.N. Lyness, is

| S ( a , c ) + S ( c , b ) S ( a , b ) | / 15 < ϵ

where [ a , b ] is an interval with midpoint c , S ( a , b ) , S ( a , c ) , and S ( c , b ) are the estimates given by Simpson's rule on the corresponding intervals and ϵ is the desired tolerance for the interval.

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 S ( a , c ) + S ( c , b ) for six function values is combined with the less accurate estimate S ( a , b ) for three function values by applying the correction [ S ( a , c ) + S ( c , b ) S ( a , b ) ] / 15 . The thus obtained estimate is exact for polynomials of degree five or less.

Python

Here is an implementation of adaptive Simpson's method in Python. Note that this is explanatory code, without regard for efficiency. Every call to recursive_asr entails six function evaluations. For actual use, one will want to modify it so that the minimum of two function evaluations are performed.

C

Here is an implementation of the adaptive Simpson's method in C99 that avoids redundant evaluations of f and quadrature computations. The amount of memory used is O(h) where h is the maximum recursion depth. Each stack frame caches computed values that may be needed in subsequent calls.

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.

The code is an excerpt of a "#lang racket" module and that includes a (require rackunit) line.

References

Adaptive Simpson's method Wikipedia