35 Numerical Integration
We have seen countless integrals in calculus and have become quite proficient in being able to evaluate integrals. We also saw how Riemann sums could be used to approximate the area under a curve by using mid-points or end points. The next two rules we will cover have a similar intention as Riemann sums the only requirement of these rules is that the integrals must be definite. As well, with using the Trapezoid and Simpson’s rule for approximation there is also the ability to calculate error just as we did previously with series.
29.1 Trapezoid Rule
We begin with the Trapezoid rule. Unlike the Riemann sums which used the sum of the areas of rectangles approximately fitted to the curve of a function to approximate the total area, with Trapezoid rule we include the area of fitted triangles associated with each rectangle. The diagram below gives the best representation to understand this concept.
We can see from this diagram that the rectangles we are familiar with from Riemann sums are built upon with triangular ends to better fit the curve. We define the formula for the Trapezoid rule as follows [37].
Theorem: Trapezoid Rule
Given the integral for from to as
We can approximate the integral using the Trapezoid rule as follows.
Where for intervals and .
The idea behind the Trapezoid rule is that the approximation will become more precise as the number of intervals grows.
Example:
Evaluate the following integral with intervals using the trapezoid rule [15].
We begin by calculating .
Now that we have found , we calculate the values for at each point starting with as always.
Now substituting our found values into the trapezoid rule function and solve for the approximation.
Now that we have established how to evaluate an integral we need to address common ways of calculating the error. First off, looking back at the previous example we were able to evaluate the integral and produce a 10 decimal answer but this is a rounded off answer, in numerical methods we call this truncation. Therefore we need to be able to calculate the error with respect to this truncation. We define the formula for this error as follows.
Truncation Error:
Given an integral for function from to . Using the Trapezoid rule to evaluate the integral we can find the truncation error of the integral as follows [16].
Definition.
Branching out we can utilize this formula in two method, either the maximum error or average error method. We have these two unique methods because within the truncation formula we have a function, . We need to be able to find the value for this if we are to complete the evaluation for the error.
Maximum Error
The maximum error is much like the approximate uncertainty we discussed in our section on analysis. We are focused on finding the greatest possible error, with this being said we would want to use the greatest value possible for . Let us consider our previous example for .
Example:
Given the following integral for , calculate the maximum error.
Let us first find the function for the second derivative of .
Next, since is an increasing function then the value for at is the greatest value produced on the interval . Thus we calculate for to be as follows.
Now we can substitute our known values into the truncation formula and find the error.
Thus we have found the greatest radius of uncertainty for our approximation of the integral, using the Trapezoid rule. Next, we look at the other method for approximating the error by the average.
Average Error
The average error requires us to calculate the average value for the derivative . The equation is given as follows.
This is the basic formula for finding the average value, when applied to the truncation error formula this means that . Thus we can rewrite the truncation error formula with [16].
Let us revisit our example again to calculate the average error of the Trapezoid rule for .
Example:
Given the following integral for , calculate the average error.
Firstly since then instead of finding the second derivative of the function we only need to find the first. Recall that our average formula utilizes such that . Thus we find the following derivative.
Now we need to calculate and . Recall that and such that we have the following.
Now that we have found all our values we can substitute them into our error formula.
We should note that the average error is smaller than the maximum error, this is to be expected. This is also very helpful if the average error is, for some reason, larger than the maximum then the calculations need to be checked again. We now move on to an improved Trapezoid rule found in the Simpson’s rule.
29.2 Simpson’s 1/3 Rule
Through countless integration problems throughout mathematics we should have noticed how our approximation of an area is improved by smaller intervals which in turn means we need a greater amount of intervals on . This is where Simpson’s rule comes in, this integration method is an improvement upon the Trapezoid rule as it utilized parabolas instead of Trapezoids to best fit the area under a curve. We can see this concept illustrated in the below diagram.
Here we can see that parabolic shapes are built upon the rectangle we know from Riemann sums. With this we can conform to the curve with better accuracy than with the Trapezoid rule’s triangular shapes. We have the formula for the Simpson’s rule as follows.
Let us use the same example as before but this time we apply the Simpson’s method.
Example:
Evaluate the following integral with intervals using the Simpson’s rule [15].
For we calculate to be as follows.
Now we find the values for each starting with .
Now that we have our values we can substitute them into our Simpson’s rule formula.
We can compare these values to what we found for this same example using the trapezoid rule, and we will see these are all very close values. What we will really tell us if an improvement has been made is by comparing the errors found for Trapezoid rule versus Simpson’s . We are given the truncation error formula for Simpson’s rule as follows.
Using the same example as before we can calculate the maximum truncation error as follows.
Example:
Given the following integral for , calculate the maximum error.
Firstly we need to find the fourth derivative for . We utilize the first two derivatives we found using Trapezoid rule
Now we can calculate at the maximum since is a decreasing function.
Now that we have all of our known values we can calculate the maximum truncation error as follows
This is a much smaller maximum truncation error than what we found using the Trapezoid rule. Let us now look at the average truncation error and compare to what we found using the Trapezoid rule. Recall that the average is calculated by the following.
Thus we can calculate the average, given the truncation for Simpson’s requires and , as the following.
Which results in the following formula for the average truncation error [16].
Now we can calculate the average truncation error for our example, this time for Simpson’s rule.
Example:
Given the following integral for , calculate the average error.
Firstly we need already found the third derivative for from the maximum error to be
Thus we can calculate the third derivative for and as follows.
Now that we have all our known values we can substitute our values in for the average truncation error formula.
Again we see that the average truncation error is much smaller for the Simpson’s rule than for the Trapezoid rule. This supports our claim that the Simpson’s rule is an improved version of the Trapezoid rule as we have seen by the simple improvement in error from Trapezoid to Simpson’s rule.
Now so far we have seen integrals with even values of . What happens if is odd? This is where Simpson’s rule is utilized.
29.3 Simpson’s 3/8 Rule
The first step of the Simpson’s rule is to separate our integral into two integrals, one with an even amount of intervals and one with the odd remaining intervals. For the integral with an even amount of interval we simply apply the Simpson’s rule. The idea behind the Simpson’s rule is that we initially want an odd integral with intervals which gives us the formula
From here we see that 3 in the numerator and the 3 in the denominator cancel each other out leaving us with the approximation formula as follows.
Utilizing a similar example to the one used to approximate with the Trapezoid and Simpson’s rule we now apply Simpson’s rule.
Example:
Evaluate the following integral using Simpson’s rules with [15].
Firstly we need to make sure is odd. We calculate by the following.
Thus we need to rewrite the integral into two, making sure to have one integral with intervals. we calculate the interval for each integral by letting thus out first integral has and and our second integral has and .
Let us evaluate the first integral using Simpson’s rule, we first calculate the values for starting with .
Now that we have found all are values, we can substitute them into our Simpson’s formula for evaluating the integral.
Now, we need to evaluate the second integral. We begin by finding our values for starting with .
Now that we have found all our values we can substitute them into our formula for Simpson’s rule for evaluating the integral.
Now we need to add the two integrals together to complete our evaluation.
Now we should evaluate the average and maximum errors to see if this is a good approximation or not. Just as Trapezoid and Simpson’s rules have their own average and maximum error formulas, the same goes for Simpson’s rule. We begin with the formula for the truncation error of Simpson’s rule.
Beginning with the maximum error we simply find when is at its maximum over the interval . In our example we split our original integral into two and applied the rule to one integral and the rule to the other, accordingly we need to find the maximum error as well.
Example:
We start with the first integral, with intervals, the integral is as follows.
In our previous calculation for the maximum truncation using Simpson’s rule we found as
If we were to graph this function we would see that this is an increasing function which means on the interval the maximum is when . Thus we can calculate the maximum truncation error.
Next, we need to calculate the maximum truncation error for the second integral.
Since this integral qualifies for Simpson’s rule we use the Simpson’s rule maximum truncation error given by the following formula.
Again since we know that is an increasing function the maximum will be reached at , thus we have the following calculation.
Just as we combined our two approximations for the evaluation of the integral, we do the same for the maximum error. Thus our maximum error for the original integral is as follows.
Next we need to calculate the average truncation error. In Simpson’s rule we are introduced to finding the average of by the formula
Keeping the truncation formula for Simpson’s rule as is we can calculate our average truncation error for our example. To calculate the average truncation error, we use the same idea of summing two truncation error calculations as we did in the example previous. This time we apply the average calculations. Firstly we know the formula for the average is given as follows.
From here we can simplify the formula for the average truncation error.
Now let us apply this formula to our example.
Example:
We begin with out first of two integrals.
We found previously in our work with Simpson’s rule.
We know and thus we calculate and .
Now we substitute these values into our formula for the average truncation error.
Next we need to calculate the average truncation error for the second integral, using Simpson’s rule. We begin with finding the values of and for and .
Now we can apply the average truncation error formula for Simpson’s rule.
Finally, we combine the two average truncation errors to find the average truncation error for the original integral.
Thus we have covered numerical integration by Trapezoid and Simpson’s rule for even values of and we addressed using Simpson’s rule for odd . We also covered how to calculate the maximum and average truncation errors for each of our approximations. From integration approximations we move to calculating the root of nonlinear equations in our next section.