Exercise on approximate integration, Friday, October 7, 2005, Math 172-502

The goal of this exercise is to deepen your understanding of methods of approximate integration by making some theoretical predictions and then testing your conjectures with the computer.

Section 8.8 in the textbook contains the background information about the left-hand-endpoint rule, the right-hand-endpoint rule, the trapezoidal rule, and the midpoint rule. These rules are built in to Maple, as you will see below.

You also need to know the form of the error bounds. The trapezoidal rule has an error of absolute value no greater than the maximum of the absolute value of the second derivative of the function on the interval times the cube of the width of the interval divided by 12 times the square of the number of subintervals. The error bound for the midpoint rule is one-half of the error bound for the trapezoidal rule.

Two functions

You are going to analyze one of the following functions.

  1. f(x)=1/(1+x^2) on the interval [0,1/sqrt(3)]
  2. g(x)=exp(2x) on the interval [0,1]

Comparison questions

  1. Compute by hand the integral of your function on the given interval.
    Confirm your answer by using Maple code similar to the following:
    int(g(x), x=0..1);
    
  2. Without doing any computation, can you predict whether the left-hand-endpoint approximation is bigger than the integral or smaller than the integral? What about the right-hand-endpoint approximation?
    Hint 1: Draw the graph with a command similar to the following:
    plot(f(x), x=0..1);
    
    Hint 2: Load the student package via the command
    with(Student[Calculus1]):
    
    Then look at the picture you get from code similar to the following:
    ApproximateInt(g(x), x=0..1, method=left, output=plot);
    
  3. Without doing any computation, can you predict whether the trapezoidal approximation is bigger than the integral or smaller than the integral?
    Hint 1: Maple knows method=trapezoid.
    Hint 2: With the default number of subintervals, the approximation is already so good that you can't tell much from the picture. Try using the additional option partition=2.
  4. Without doing any computation, can you predict whether the midpoint approximation is bigger than the integral or smaller than the integral?
    Hint: How does the area of a rectangle change if you convert the rectangle into a trapezoid by rotating the top edge about its midpoint?

Accuracy questions

  1. If you double the number of subintervals in the trapezoidal approximation, what would you expect the effect on the error to be?
  2. Test your answer to the preceding question by computing the trapezoidal approximations for your function with 2, 4, 8, 16, and 32 subintervals.
    Hint 1: Maple code similar to the following computes a numerical value for the difference between the integral and the trapezoidal approximation with 2 subintervals.
    evalf(Int(f(x),x =0..1)-ApproximateInt(f(x),x=0..1,method=trapezoid,partition=2));
    
    Hint 2: You can run a loop in Maple with code like the following.
    for i from 1 to 5 do
       some command depending on i
    end do;
    
  3. Can you predict how many subintervals would be needed for the trapezoidal method to approximate the integral of your function with error less than 10-10?
  4. Test your answer to the preceding question by doing a numerical computation of the error with Maple.
    Hint: Maple works to 10 significant figures by default. You can get more decimal places by giving an extra argument to the evalf command. For example, evalf[20](Pi); gives the number pi to 19 decimal places (20 significant figures).