Next: Romberg integration
Up: Assignment 3: Quadrature
Previous: Basic quadrature
- 1.
- Use the loop on page 122 of the book to evaluate the Composite
Midpoint rule for the same f(x), using 2, 4, and 8 intervals.
Notice that unlike for the other Composite rules, the Midpoint
rule uses n in a weird way that does not correspond to the
number of subintervals. I suggest that you create a variable
called intervals, and set n := 2 * (intervals-1);
- 2.
- Write a similar loop to evaluate the Composite Trapezoid rule.
Hints: The Maple interface for editing is not as wonderful as we would
like, so it might be a good idea to write your loop on paper before
you type it in. Also, note that the calculation of h and the
xi is different for the Trapezoid rule, so don't just look at
what's in the blue box.
- 3.
- Use your loop to evaluate the Trapezoid rule with 2, 4 and
8 intervals.
- 4.
- Make a table that shows all eight estimates (two rules, 1, 2, 4,
and 8 intervals), and for each estimate, calculate the absolute error
and the number of times f(x) was evaluated to get the estimate
(again, be careful about the fact that for the Midpoint rule n is
not the number of subintervals. Overall, which method seems to
be more efficient?
- 5.
- Use either your loop or the book's loop to answer Question 11
on page 124. Notice that the function is symmetric around zero, if
that gives you any ideas.
Next: Romberg integration
Up: Assignment 3: Quadrature
Previous: Basic quadrature
Allen B. Downey
1998-10-01