Homework due on Wednesday September 20.

Problem 1

Redo the first plotting problem from last week's homework as follows: create a file called "plot_fig.m" This file will have a sequence of matlab commands, starting with "x = -3:.1:3;" and ending with "axis([-3,3,-10,10]);" When you type the command "plot_fig" at the matlab prompt, the three plots will all happen in one window. Now modify plot_fig.m so you first do the plots over [-.1,.1] in figure(1), then do the plots over [-1,1] in figure(2), and finally do the plots over [-3,3] in figure(3).

Hand in printouts of both versions of plot_fig.m Note: these are examples of "matlab scripts". Using scripts, you can execute a whole bunch of commands at once. They're a very helpful way to save you typing!

Problem 2

Download the *.m files on integration from the "On Numerical Integration" link.
First, repeat the demonstration I did in class with sin(kx), but do it with f(x) = x, x^2, x^6, x^10, and x^20. Do the integrals over [0,1]. Present the errors using the left-hand rule, the trapezoidal rule, and Simpsons rule, using h = .01 (careful --- that's 101 meshpoints, not 100!)
Plot the five functions, discuss the behavior of the errors, and relate this to the plot.

Problem 3

Now, repeat the demonstration I did in class with x^6. But this time, you will keep track of the flop counts. First, take f(x) = cos(x) and integrate over [1,2].

NOTE: type "format short e" before doing the following so you have five significant figures at all times!"

Start with n=101 meshpoints. For the left-hand rule, set the tolerance to 10^(-4). The routine prints out the error at each step that it tries. What is the ratio of the each error divided by the subsequent error? Present this in a table.

Start with n=101 meshpoints. For the trapezoidal rule, set the tolerance to 10^(-9). The routine prints out the error at each step that it tries. What is the ratio of the each error divided by the subsequent error? Present this in a table.

Start with n=51 meshpoints. For the Simpsons rule, set the tolerance to 10^(-14). The routine prints out the error at each step that it tries. What is the ratio of the each error divided by the subsequent error? Present this in a table.

Look in the code left_hand_filter.m How does h, the length of a subinterval, change with each attempt? (Check that it changes in the same way in trap_filter.m and simp_filter.m) Use your above work to write a rule of thumb that tells you how the error changes with each attempt. (Your rule will depend on the method.)

Now, modify left_hand_filter.m, trap_filter.m, and simp_filter.m so that the number of intervals *triples* with every attempt. Repeat the above exercise, modifying the tolerances, if need be, so you get at least five error-values for each method. How do your results relate to your rule of thumb? (Give me a printout of your modified left_hand_filter.m program!)

Pen and Paper problems

Section 1.1

Problems 2d, 3e, 8, 10

Section 1.2

Problems 5, 6, 13, 16