Homework 3, due Mon Oct 4 at midnight

Late policy: late homework will be penalized 20% (because it makes life much more difficult for the grader when homework is late). Homework will generally not be accepted more than a week late, except in special circumstances. Homework can left under my door tonight (Sept 27), as I will get it tomorrow morning; don't leave it under my door after tonight, but bring it to class next week instead.

If you have not already done so, please join the class mailing list!

Please submit function and script source code listings (not hand written!!!) and graphics output, as well as written (by hand or typed) answers to the questions. It is not necessary to print the MATLAB command sessions.

  1. Ex 7.2 and Ex 7.5, p.55 of the text. Note that for 7.2, you can assume A has full rank, although it does not say so in the first printing of the text.

  2. Write a Matlab function legendpoly to compute the first n Legendre polynomials evaluated on p equally spaced points on the interval [-1,1], following the model on p.64 of the text, normalized as at the bottom of p.64 (see also p.53). Include a third input argument to the function which determines whether to call the classical Gram Schmidt function clgs(A) (see clgs.m ) or the built-in Matlab QR (economy-size) function qr(A,0) . In either case, A is the matrix whose columns are the monomials evaluated at the points in the interval.

  3. In the Matlab workspace, call legendpoly with various choices of input parameters, plotting the resulting Legendre polynomials. For larger n you may not want to plot all of them. How large does n have to get before classical Gram-Schmidt is so inaccurate that the plot is visibly different from the one you get with the built-in QR? Show both sets of polynomials on the same graph, using different plot marks (use hold on ) so the difference is clear. (Type help plot to find out what plot marks are available; if you have access to a color printer, use colors instead, but this is not necessary.)

  4. Write two Matlab functions Do this by getting a copy of clgs.m and editing it accordingly, changing the comments as well as the code. Include enough comments to convince the reader that you understand why these programs are mathematically equivalent to classical Gram-Schmidt and to each other, instead of just blindly copying the algorithms. Save the programs in files called mgs1.m and mgs2.m . Ignore breakdown, which means division by zero may occur if the matrix is not full rank (rounding errors may prevent this breakdown). Carefully debug your programs by testing them on small (even very small!) examples first. When they are working, add a third option to legendpoly to call them as alternatives to clgs and qr, and check their accuracy: how do the accuracy of the plots compare with the plots obtained with clgs and qr ?

  5. Write a Matlab script to reproduce Figure 9.1 (p. 66), but showing the results for all 4 QR routines clgs, mgs1, mgs2 and qr (economy-sized), plotting the results with 4 different marks. Use the example on p.65. You may want to type help semilogy (semi-log plots) and help script (to learn the difference between functions and scripts).

I will be out of town and mostly away from email the rest of the week, so if you need help, try sending email to mconsult@cims or to the class mailing list (join the list first, and be sure to send email from the same account that you registered with the list, or your email will not be posted to the list). I should be able to reply to email next Monday morning (Oct 4).