Simpson’s 1/3 Method for Numerical Integration

by admin in , , on April 29, 2019

This code calculates the Numerical Integration of a given equation on a predefined interval using Simpson’s 1/3 Rule. This codes uses variable step size so it gives accurate results.

Code Outputs:

  • Chart of Integration History
  • Chart of Residuals
  • Printed values of Final Iteration value, Accuracy and Number of Iterations.

Result is: 0.96645, Accuracy: 0.00097575, NO of Iterations: 53

Input Requirements:

  • The equation you intended to integrate
  • Integration interval [a b].
  • predefined error (default 0.001).
  • Maximum number of iterations (default 50000).

About Simpson’s 1/3 Rule:

For Simpson’s voting rule, see Minimax Condorcet. For Simpson’s rules used in ship stability, see Simpson’s rules (ship stability).

Simpson’s rule can be derived by approximating the integrand (x) (in blue) by the quadratic interpolant P(x) (in red).

An animation showing how Simpson’s rule approximation improves with more strips.

In numerical analysis, Simpson’s rule is a method for numerical integration, the numerical approximation of definite integrals. Specifically, it is the following approximation for n+1 equally spaced subdivisions (where n is even): (General Form)

,

where dx = (b-a)/n and xi = a + i.dx.

Simpson’s rule also corresponds to the three-point Newton-Cotes quadrature rule.

In English, the method is credited to the mathematician Thomas Simpson (1710–1761) of Leicestershire, England. However, Johannes Kepler used similar formulas over 100 years prior, and for this reason the method is sometimes called Kepler’s rule, or Keplersche Fassregel (Kepler’s barrel rule) in German.

Composite Simpson’s 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, what we really mean is 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 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 [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 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

where xi = a + jh for j = 0,1,…,n-1,n with h = (b-a)/n; in particular, x0 = a and xn = b. 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

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

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.

References:

[1] Atkinson, Kendall E. (1989). An Introduction to Numerical Analysis (2nd ed.). John Wiley & Sons. ISBN 0-471-50023-2.

[2] Burden, Richard L.; Faires, J. Douglas (2000). Numerical Analysis (7th ed.). Brooks/Cole. ISBN 0-534-38216-9.

[3] Pate, McCall (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.

[4] 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.

[5] 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.

[6] Süli, Endre; Mayers, David (2003). An Introduction to Numerical Analysis. Cambridge University Press. ISBN 0-521-00794-1.

[7] Kaw, Autar; Kalu, Egwu; Nguyen, Duc (2008). ‘Numerical Methods with Applications’.

[8] Weisstein, Eric W. (2010). ‘Newton-Cotes Formulas’. MathWorld–A Wolframtite Web Resource. MathWorld. Retrieved 2 August 2010.

2 Sales

Share Now!

Release Information

  • Price
    :

    $4.99

  • Released
    :

    April 29, 2019

  • Last Updated
    :

    May 28, 2019

Share Your Valuable Opinions