 # 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).

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.

Share Now!

#### Release Information

• Price
:

\$4.99

• Released
:

April 29, 2019

• Last Updated
:

May 28, 2019