The simpsons rule is a method of calculating, in an approximate way, the definite integrals. It is based on dividing the integration interval into an even number of equally spaced sub-intervals.
The extreme values of two consecutive sub-intervals define three points, by which a parabola, whose equation is a second-degree polynomial, fits.
Then the area under the curve of the function in the two consecutive intervals is approximated by the area of the interpolation polynomial. Adding the contribution to the area under the parabola of all the successive sub-intervals, we have the approximate value of the integral.
On the other hand, since the integral of a parabola can be calculated algebraically exactly, then it is possible to find an analytic formula for the approximate value of the definite integral. It is known as the Simpson's formula.
The error of the approximate result thus obtained decreases as the number of subdivisions n is greater (where n is an even number).
An expression will be given below that allows estimating the upper bound of the error of the approximation to the integral I, when a partition of n regular subintervals of the total interval has been made [a, b].
Article index
The integration interval [a, b] is subdivided into n subintervals with n being an even integer. The width of each subdivision will be:
h = (b - a) / n
In this way, on the interval [a, b] the partition is made:
X0, X1, X2,…, Xn-1, Xn
Where X0 = a, X1 = X0 + h, X2 = X0 + 2h,…, Xn-1 = X0 + (n-1) h, Xn = X0 + nh = b.
The formula that allows to approximate the definite integral I of the continuous, and preferably smooth, function on the interval [a, b] is:
To obtain Simpson's formula, in each subinterval [Xi, Xi + 2] the function f (X) is approximated by a second degree polynomial p (X) (parabola) that passes through the three points: [Xi, f ( Xi)]; [Xi + 1, f (Xi + 1)] and [Xi + 2, f (Xi + 2)].
Then we calculate the integral of the polynomial p (x) in [Xi, Xi + 2] that approximates the integral of the function f (X) in that interval.
The equation of the parabola p (X) has the general form: p (X) = A Xtwo + B X + C. As the parabola passes through the points Q indicated in red (see figure), then the coefficients A, B, C are determined from the following system of equations:
A (-h)two - B h + C = f (Xi)
C = f (Xi + 1)
A (h)two + B h + C = f (Xi + 2)
It can be seen that the coefficient C is determined. To determine the coefficient A we add the first and third equations obtaining:
2 A htwo + 2 C = f (Xi) + f (Xi + 2).
Then the value of C is substituted and A is cleared, leaving:
A = [f (Xi) - 2 f (Xi + 1) + f (Xi + 2)] / (2 htwo)
To determine the coefficient B, the third equation is subtracted from the first and B is solved, obtaining:
B = [f (Xi + 2) - f (Xi)] = 2 h.
In summary, the second degree polynomial p (X) that passes through the points Qi, Qi + 1 and Qi + 2 has coefficients:
A = [f (Xi) - 2 f (Xi + 1) + f (Xi + 2)] / (2 htwo)
B = [f (Xi + 2) - f (Xi)] = 2 h
C = f (Xi + 1)
As already mentioned, on the total integration interval [a, b] a partition is made X0, X1, X2,…, Xn-1, Xn with step h = Xi + 1 - Xi = (b - a ) / n, where n is an even number.
Note that the error decreases with the fourth power of the number of subdivisions in the interval. For example, if you go from n subdivisions to 2n, then the error decreases by a factor 1/16.
The upper bound of the error obtained by means of the Simpson approximation can be obtained from this same formula, substituting the fourth derivative for the maximum absolute value of the fourth derivative in the interval [a, b].
Consider the function the function f (X) = 1 / (1 + Xtwo).
Find the definite integral of the function f (X) on the interval [-1, 1] using Simpson's method with two subdivisions (n = 2).
We take n = 2. The limits of integration are a = -1 and b = -2, so the partition looks like this:
X0 = -1; X1 = 0 and X2 = +1.
Therefore, Simpson's formula takes the following form:
With n = 2 → xo = -1, x1 = 0; x2 = 1, therefore:
Consider the function f (X) = 1 / (1 + Xtwo).
Find the definite integral of the function f (X) on the interval [-1, 1] using Simpson's formula with four subdivisions (n = 4).
We take n = 4. The limits of integration are a = -1 and b = -2, so the partition looks like this:
X0 = -1; X1 = -1/2; X2 = 0; X3 = 1/2 and X4 = +1.
Simpson's formula is stated like this:
Integral ≃ [(b -a) / (3 n)] [f (X0) + 4 I + 2 P + f (Xn)]
For the case in which it is being applied, it is as follows:
Integral ≃ (1 - (1)) / (3⋅4)] [f (-1) + 4 [f (-½) + f (½)] + 2 [f (0)] + f (1)
Integral ≃ (2/12) [½ + 4 (⅘ + ⅘) + 2⋅1 + ½] = (⅙) [47/5] = 47/30 = 1.5666
Determine the definite integral of the previous examples exactly and make a comparison of the exact result with those obtained using Simpson's formula in examples 1a and 1b.
The indefinite integral of the function f (X) = 1 / (1 + Xtwo) is the function arctan (X).
When evaluating in the limits of integration it remains:
Integral = arctan (1) - arctan (-1) = π / 4 - (-π / 4) = π / 2 = 1.5708
If we compare the result of the exact solution with that obtained by Simpson's method with n = 2 and n = 4, we have:
For n = 2, the difference between the exact and the approximate solution is π / 2 - 5/3 = -0.0959, that is, a percentage difference of -0.06%.
And for the Simpson approximation with n = 4, the difference between the exact and the approximate solution is π / 2 - 47/30 = 0.0041, that is, a percentage difference of 0.003%.
Simpson's method is suitable to be applied in programming languages and in computer applications for mathematical calculations. It is suggested that the reader, based on the formulas given in this article, write his own code in his favorite program.
The following figure shows an exercise in which Simpson's formula has been implemented in Smath studio, free software available for operating systems Windows Y Android.
Yet No Comments