Mathematics 136 – Calculus 2 Lab Day 2 – “In search of a better numerical integral method” November 2 and 4, 2016

Background

Yesterday in class we discussed the L_{N}, R_{N}, M_{N}, and T_{N} methods for approximating definite integrals (the left-, right-, and midpoint Riemann sums were not new; the trapezoidal method was new). We have seen the following patterns (some more than once!):

• If f is increasing on [a, b], then L_{N} gives an underestimate of ∫_{a}^{b} f(x) dx for all n. If f is decreasing on [a, b], then L_{N} gives an overerestimate of ∫_{a}^{b} f(x) dx for all n.

• If f is decreasing on [a, b], then R_{N} gives an undererestimate of ∫_{a}^{b} f(x) dx for all n. If f is increasing on [a, b], then R_{N} gives an overerestimate of ∫_{a}^{b} f(x) dx for all n.

• Whether T_{N} is an under- or over-estimate of ∫_{a}^{b} f(x) dx depends on the concavity of f. If f is concave up on [a, b], then T_{N} will give an overestimate of the integral. If f is concave down on [a, b], then T_{N} will give an underestimate of the integral.

• Whether M_{N} is an under- or over-estimate of ∫_{a}^{b} f(x) dx also depends on the concavity of f, and we want to understand this as well.

Today, we will gather some data on these methods by looking at several examples, and introduce an even better method obtained by combining two of these methods in an appropriate way.

Maple Commands and Examples

The commands for finding the left, right, and midpoint sums and trapezoidal rule approximations are contained in the Student[Calculus1] package. Launch Maple as we did in the first lab. (The information sheet on Maple is posted on the course homepage if you need a refresher.) Start by entering

                         with(Student[Calculus1]);

to load this. The command we will use in the lab is:

• ApproximateIntTutor which draws graphical representations of the left-, midpoint, and right-hand Riemann sums, trapezoidal rule, and several other approximation methods for a given function, and

Enter the command

                          ApproximateIntTutor();

This should display a pop-up window with a “default” function, interval, N value, a graph and approximate value of the integral. You can change the f(x), the a, b, the N and the method used. For instance, enter exp(-x^2/2)/sqrt(2*Pi) in the box for f(x), make a = 0, b = 0.5 and N = 4. Then set the button under the Riemann Sums heading to left. When you press the Display button, the L_{4} approximation is displayed under the new graph, together with the “actual area” which is Maple’s best approximation to

∫_{0}^{0.5} \frac{1}{\sqrt{2π}} e^{−x^{2}/2} dx.

To change method, or change the function or N or a, b for the interval, just update the corresponding input boxes and/or button settings in the pop-up. Then press Display again.

Lab Problems

A) For each of the following integrals,

1) Compute L_{N}, R_{N}, M_{N}, and T_{N} approximations for N = 5, 10, 20, 40, 80. Round all approximate values (including the “actual value”) to 6 decimal places. Record your answers by hand on the attached data sheets. (Note that there is an extra column at the end that will only be filled in later.)

2) Note the “actual area” value produced every time you Display. We will take that as the “actual value” of the integral for the purposes of this lab.

3) Compute the errors (either by hand or by using Maple as a calculator) this way:

Error = approximate value − actual value

without taking the absolute value, including the sign. (A negative sign means that the approximate value is smaller than the exact value, and a positive sign means that the approximate value is larger than the exact value.) Integrals:

1) ∫_{0}^{3/2} e^{−x^{4}/10} dx (enter the function as exp(-x^4/10))

2) ∫_{2}^{4} \frac{sin x}{x} dx (enter the function as sin(x)/x)

B) Now we want to look for some patterns in our data. Answer the following questions by hand on a separate sheet of paper.

1) For each integral and each method separately, do you notice any consistent pattern when you compare the size of the error with a given N and with N twice as large (e.g. the error for M_{10} vs. the error for M_{20}, or the error for T_{40} vs. the error for T_{80})? Is the pattern the same for all of the methods, or does it vary?

2) Do you notice any consistent pattern when you compare the sizes of the errors for the four different methods on the same integral, with the same N? In particular, what is the approximate relation between the size of the errors for the T and M methods (for the same integral and the same N), and how are the signs of the two errors related?

3) How is the sign of the error for M_{N} related to the concavity of y = f(x) on the interval [a, b]? (You can determine the concavities from the plots produced in the

ApproximateIntTutor pop-up.)

C) One commonly-used better integration method is called Simpson’s Rule (no, it’s not named for Homer Simpson!) One way to write the formula for Simpson’s rule is:

S_{N} = \frac{2 · M_{N} + T_{N}}{3}

There is another button in the ApproximateIntTutor pop-up that computes this method to compute approximate values of integrals.

1) Try it on the examples from question A, and compare the sizes of the errors for Simpson’s Rule and the other methods for each N = 5, 10, 20, 40, 80.

2) Why is Simpson’s Rule apparently more accurate? (Hint: Think about your answer to part 2 of question B).

Assignment

Individual lab write-ups, due no later than 5pm on Tuesday, November 8 (Election Day, finally!!!!!).

Table 1.

∫_{0}^{3/2} e^{−x^{4}/10} dx Actual value:

Left Right Midpoint Trapezoid Simpson

N = 5: Error: N = 10: Error: N = 20: Error: N = 40: Error: N = 80: Error:

Table 2.

∫_{2}^{4} \frac{sin(x)}{x} dx Actual value:

Left Right Midpoint Trapezoid Simpson

N = 5: Error: N = 10: Error: N = 20: Error: N = 40: Error: N = 80: Error: