Numerical Integration: Simpson’s Rules
11.4.1 Simpson’s ⅓ Rule
Let . By dividing the interval into many subintervals, the Simpson’s 1/3 rule approximates the area under the curve in every subinterval by interpolating between the values of the function at the midpoint and ends of the subinterval, and thus, on each subinterval, the curve to be integrated is a parabola. For simplicity, the width of each subinterval is chosen to be constant and is equal to . Let be the number of intervals with and constant spacing . On each interval with end points and , Lagrange polynomials can be used to define the interpolating parabola as follows:
where is the midpoint in the interval . Integrating the above formula yields:
The Simpson’s 1/3 rule can be implemented as follows:
The following tool illustrates the implementation of the Simpson’s 1/3 rule for integrating the function defined as:
Use the slider to see the effect of increasing the number of intervals on the approximation.
The following Mathematica code can be used to numerically integrate any function on the interval using the Simpson’s 1/3 rule.
View Mathematica Code View Python CodeThe following link provides the MATLAB codes for implementing the Simpson’s 1/3 rule.
Error Analysis
One estimate for the upper bound of the error can be derived similar to the derivation of the upper bound of the error in the trapezoidal rule as follows. Given a function and its interpolating polynomial of degree (), the error term between the interpolating polynomial and the function is given by (See the Mathematical Background section for a proof):
Where is in the domain of the function . The error in the calculation of the integral of the parabola number connecting the points , , and will be estimated based on the above formula assuming . Therefore:
Therefore, the upper bound for the error can be given by:
If is the number of subdivisions, where each subdivision has width of , i.e., , then:
However, it can actually be shown that there is a better estimate for the upper bound of the error. This can be shown using Newton interpolating polynomials through the points . The reason we add an extra point is going to become apparent when the integration is carried out. The error term between the interpolating polynomial and the function is given by:
where and is dependent on . The first three terms on the right-hand side are exactly the interpolating parabola passing through the points , , and . Therefore, an estimate for the error can be evaluated as:
The first term on the right-hand side of the inequality is equal to zero. This is because the point is the average of and , so, integrating that cubic polynomial term yields zero. This was the reason to consider a third-order polynomial instead of a second-order polynomial which allows the error term to be in terms of . If is the number of subdivisions, where each subdivision has width of , i.e., , then:
Example
Using the Simpson’s 1/3 rule with , calculate and compare with the exact integral of the function on the interval . Find the value of so that the error is less than 0.001.
Solution
It is important to note that defines the number of intervals on which a parabola is defined. Each interval has a width of . Since the spacing can be calculated as:
Therefore, , , , , and . The values of the function at these points are given by:
According to the Simpson’s 1/3 rule we have:
Which is already a very good approximation to the exact value of even though only 2 intervals were used.
Error Bounds
The total error obtained when is indeed less than the error bounds obtained by the formula listed above. For , the error in the estimation is bounded by:
The error evaluated by is indeed less than that upper bound. The same formula can be used to find the value of so that the error is bounded by 0.001:
Therefore, to guarantee an error less than 0.001 using , the interval will have to be divided into: intervals where a parabola is defined on each! In this case, the value of and .
11.4.2 Simpson’s ⅜ Rule
Let . By dividing the interval into many subintervals, the Simpson’s 3/8 rule approximates the area under the curve in every subinterval by interpolating between the values of the function at the ends of the subinterval and at two intermediate points, and thus, on each subinterval, the curve to be integrated is a cube. For simplicity, the width of each subinterval is chosen to be constant and is equal to . Let be the number of intervals with and constant spacing with the intermediate points for each interval as and . On each interval with end points and , Lagrange polynomials can be used to define the interpolating cubic polynomial as follows:
Integrating the above formula yields:
The Simpson’s 3/8 rule can be implemented as follows:
The following tool illustrates the implementation of the Simpson’s 3/8 rule for integrating the function defined as:
Use the slider to see the effect of increasing the number of intervals on the approximation.
The following Mathematica code can be used to numerically integrate any function on the interval using the Simpson’s 3/8 rule.
View Mathematica Code View Python CodeThe following link provides the MATLAB codes for implementing the Simpson’s 3/8 rule.
Error Analysis
The estimate for the upper bound of the error can be derived similar to the derivation of the upper bound of the error in the trapezoidal rule as follows. Given a function and its interpolating polynomial of degree (), the error term between the interpolating polynomial and the function is given by (See the Mathematical Background section for a proof):
Where is in the domain of the function . The error in the calculation of the integral of the cubic function number connecting the points , , , and will be estimated based on the above formula assuming . Therefore:
Therefore, the upper bound for the error can be given by:
If is the number of subdivisions, where each subdivision has width of , i.e., , then:
Example
Using the Simpson’s 3/8 rule with , calculate and compare with the exact integral of the function on the interval . Find the value of so that the error is less than 0.001.
Solution
It is important to note that defines the number of intervals on which a cubic polynomial is defined. Each interval has a width of . Since the spacing can be calculated as:
Therefore, , , , and . The values of the function at these points are given by:
According to the Simpson’s 3/8 rule we have:
Which is already a very good approximation to the exact value of even though only 1 interval was used.
Error Bounds
The total error obtained when is indeed less than the error bounds obtained by the formula listed above. For , the error in the estimation is bounded by:
The error is indeed less than that upper bound. The same formula can be used to find the value of so that the error is bounded by 0.001:
Therefore, to guarantee an error less than 0.001 using , the interval will have to be divided into: intervals where a cubic polynomial is defined on each! In this case, the value of and .