#Numerical Integration
Some antiderivatives are difficult (or impossible) to compute. In such cases, numerical approximation of a definite integral may be a better (or the only) option.
In Calculus 1, we learned about the "numerical_integral" command in Sage. We are not going to use this command in this lab. Instead, we will explore various approximation techniques.
##Riemann Sums
The simplest numerical approximation comes from the definition of the definite integral as a limit of Riemann sums. Each Riemann sum is an approximation of the definite integral using rectangles (with one side on the x-axis), and we can make the approximation better by increasing the number of rectangles.
Our goal is to approximate .
We will use rectangles of equal width, which means the width of each rectangle is .
The height of the rectangle will be given by the value of the function at some point in the base of that rectangle.
If we choose the left endpoint of each rectangle, we will find the left Riemann sum. If we choose the right endpoint of each rectangle, we will find the right Riemann sum.
The endpoints of the rectangles are .
So the left Riemann sum is .
Similarly, the right Riemann sum is .
The only difference in these formulas is the index of summation.
###Example 1
Consider .
Here are pictures with rectangles.
The formulas below compute the left and right Riemann sums.
For the sake of comparison, the exact value is .
If you want to graph or compute any other left or right sums, you may copy and paste the above formulas and change , , , and . Leave everything else!
Let's change the number of rectangles to 10 and see how our approximation improves.
Remember that the exact answer is . Both of these are closer to the correct answer than before, but they are still not very close.
Of course, we can increase our accuracy by using larger values of , but it would be very nice if there were more accurate approximation methods. Fortunately, there are.
##Midpoint and Trapezoidal Rules
The Midpoint Rule is another Riemann sum approximation, but instead of using the left or right endpoints, we will use the midpoint of each rectangle.
Using the midpoint of each rectangle as a height often leads to better estimates with a similar number of rectanges compared to the left or right points. Notice that using right endpoints an increasing function will be consistantly overestimated and left end points underestimated. With midpoints these over and underestimates tend to cancel giving a better overall approximation.
###Example 2
Consider .
Here is a plot and calculation for the Midpoint Rule using .
The exact value is , and the Midpoint Rule gives us the correct answer to two decimal places with only 5 rectangles.
Recall that for , the left sum was 0.12 and the right sum was 0.22. The Midpoint Rule has done a good job of balancing out the under- and over-estimates. However, if our function was not so nicely behaved (here the function is similar on bothsizes of the midpont) the midpoint rule may not benefit from the cancellation effect.
So far we have been approximating our function using a constant (horizontal line = degree 0 polynomial) on each subinterval.
We may be able to improve our approximation if we use a degree 1 polynomial instead (i.e., a non-horizontal line). For each subinterval, we’ll use the secant line based on the left and right endpoints. Of course, the resulting shape is not a rectangle but a trapezoid. Thus, this approach is called the Trapezoidal Rule.
Recall that the area of a trapezoid is where and are the lengths of the bases and the height. In this case, the trapezoid is sitting on its side, so the bases are actually vertical and the height is .
###Example 3
Consider
Here is the plot and calculation for the Trapezoidal Rule using .
Notice that this approximation is slightly worse than what we got from the Midpoint Rule, but it is much better than either the left or right sum.
In fact, numerically the Trapezoidal Rule simply gives the average of the left and right sums!
In general (but not always), the Midpoint Rule will give a better approximation. If the function is either concave up or concave down on the entire subinterval, then the linear approximation from the Trapezoidal Rule (the secant line) will be entirely above or below the curve. On the other hand, the horizontal line segment from the Midpoint Rule will be above the curve on part of the interval and below the curve on part of the interval, so the errors will cancel out.
Despite this numerical disappointment, the idea of increasing the degree of the approximating polynomial was sound. The next step is to use a degree 2 polynomial (quadratic, parabola) to approximate on each subinterval. This is called Simpson's Rule.
##Simpson's Rule
Instead of using a line to approximate our curve on each subinterval, we will use a parabola. Since a parabola is usually closer to the curve than a line, this should give us a better approximation (of course, this is not true if our original curve is a line, but in that case, why are we approximating the integral?).
A line is determined by 2 points, but it takes 3 points to determine a parabola.
The three points that are normally used are the left endpoints of three consecutive subintervals. This choice forces us to use an even number of subintervals (i.e., must be even).
I won't take you through all the calculations (see the textbook, pages 463-465).
###Example 4
Consider .
Here is the result for Simpson's Rule using . (I'll skip the graph. If you really want to see one, there is an example at the end of this worksheet.)
Notice we obtain an exact answer utilizing Simpson's Rule. This should not be too surprizing as our function was a parabola in the first place.
It is interesting to note that numerically the answer from Simpson's Rule is a weighted average of the answers from the Trapezoidal Rule and the Midpoint Rule (with half the number of rectangles). In particular, if is the approximation from Simpson's Rule with subintervals, is the approximation from the Trapezoidal Rule with trapezoids, and is the approximation from the Midpoint Rule with rectangles, then
###Example 5 (and a one-stop shop for cut-and-paste)
Here is one example that puts all the rules together. (I'll skip the graphs again.).
Let's approximate using , , and .
For comparison, the exact answer is .
To summarize: , and the exact value is .
Now let's try :
To summarize: , and the exact value is .
Now let's try :
To summarize: , and the exact value is .
What do we see from this example?
All the approximations improve as increases (except for Simpson's, which gives the exact answer for any cubic polynomial).
The left and right Riemann sums are not very good approximations.
The Midpoint Rule and Trapezoidal Rule are better than the left and right sums.
The Midpoint Rule is better than the Trapezoidal Rule.
Simpson's Rule is the best.
###Example 6 - Simpson's Rule Graph
The function to be integrated in in black. The red vertical lines mark the ends of each parabola. The approximating parabolas are in blue.
I have set . Try changing this and see how fast the parabolas get close to the original curve.
#Numerical Integration Assignment
###Question 1
The Golden Gate Bridge has a main span of 4,200 feet (the distance between the two towers). The main suspension cables that support the road over this span each form a parabolic shape. The length of each cable is found by
####Part a
Approximate the value of this integral using left and right Riemann sums, the Midpoint Rule, the Trapezoidal Rule, and Simpson's Rule using , , and .
####Part b
What is your best approximation for the length of each cable (round to one decimal place)? How confident are you in this approximation?
###Question 2 Consider the integral
####Part a
Use the Midpoint Rule with to approximate this integral.
####Part b
Approximate this integral with the Midpoint Rule using three more values of .
####Part c
What happens to your approximations as increases? What do you conclude about the integral?
###Question 3
Consider the function over the interval .
####Part a
Approximate the area under this curve using the Midpoint Rule, Trapezoidal Rule, and Simpson's Rule using , , , and .
####Part b
Rounding to one decimal place, this area is actually . For each of the three rules, which of the four values of give the correct answer (when rounding to one decimal place)?
###Question 4
Consider the function over the interval . Using our appoximation routines, what well known number is the value of close to? Hint: The interval width is , pick an appropriate number of approximating intervals!