Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Assignment for Numerical Linear Algebra | MATH 477, Assignments of Linear Algebra

Material Type: Assignment; Class: Numerical Linear Algebra; Subject: Mathematics; University: Illinois Institute of Technology; Term: Fall 2006;

Typology: Assignments

Pre 2010

Uploaded on 08/18/2009

koofers-user-pra
koofers-user-pra 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Math 477/577 Computer Assignment 4, due Oct.26, 2006
1. Take m= 50, n= 12. Using MATLAB’s linspace, define tto be the m-vector corresponding
to linearly spaced grid points from 0 to 1. using MATLAB’s vander and fliplr, define Ato
be the m×nmatrix associated with least squares fitting on this grid by a polynomial of degree
n1. Take bto be the function cos(4t) evaluated on the grid. Now, calculate and print (to
sixteen-digit precision) the least squares coefficient vector xby six methods:
(a) Formation and solution of the normal equations, using MATLAB’s \,
(b) QR factorization computed using the mgs routine from Computer Assignment 3,
(c) QR factorization computed via the house routine from Computer Assignment 3,
(d) QR factorization computed by MATLAB’s qr,
(e) x=A\bin MATLAB,
(f) SVD, using MATLAB’s svd.
(g) The calculations above will produce six lists of twelve coefficients. In each list, shade with
red pen the digits that appear to be wrong (affected by rounding error). Comment on what
differences you observe. Do the normal equations exhibit instability? You do not have to
explain your observations.
2. The usual Gaussian elimination algorithm involves a triply nested loop. The version given
in the classnotes (as LU factorization) involves two explicit for-loops, and the third loop is
implicit in the vectors U(j, k :m) and U(k, k :m). Rewrite this algorithm with just one
explicit for-loop indexed by k. Inside this loop, Uwill be updated at each step by a certain
rank-one outer product. This “outer product” form of Gaussian elimination may be a better
starting point than the LU factorization algorithm from the classnotes if one wants to optimize
computer performance. Implement both the LU factorization algorithm from the classnotes and
the “outer product” version discussed here, and test and time them both with the matrices A =
gallery(’lehmer’,N) for N=100*[1:10].

Partial preview of the text

Download Assignment for Numerical Linear Algebra | MATH 477 and more Assignments Linear Algebra in PDF only on Docsity!

Math 477/577 — Computer Assignment 4, due Oct.26, 2006

  1. Take m = 50, n = 12. Using MATLAB’s linspace, define t to be the m-vector corresponding to linearly spaced grid points from 0 to 1. using MATLAB’s vander and fliplr, define A to be the m × n matrix associated with least squares fitting on this grid by a polynomial of degree n − 1. Take b to be the function cos(4t) evaluated on the grid. Now, calculate and print (to sixteen-digit precision) the least squares coefficient vector x by six methods:

(a) Formation and solution of the normal equations, using MATLAB’s , (b) QR factorization computed using the mgs routine from Computer Assignment 3, (c) QR factorization computed via the house routine from Computer Assignment 3, (d) QR factorization computed by MATLAB’s qr, (e) x = A \ b in MATLAB, (f) SVD, using MATLAB’s svd. (g) The calculations above will produce six lists of twelve coefficients. In each list, shade with red pen the digits that appear to be wrong (affected by rounding error). Comment on what differences you observe. Do the normal equations exhibit instability? You do not have to explain your observations.

  1. The usual Gaussian elimination algorithm involves a triply nested loop. The version given in the classnotes (as LU factorization) involves two explicit for-loops, and the third loop is implicit in the vectors U (j, k : m) and U (k, k : m). Rewrite this algorithm with just one explicit for-loop indexed by k. Inside this loop, U will be updated at each step by a certain rank-one outer product. This “outer product” form of Gaussian elimination may be a better starting point than the LU factorization algorithm from the classnotes if one wants to optimize computer performance. Implement both the LU factorization algorithm from the classnotes and the “outer product” version discussed here, and test and time them both with the matrices A = gallery(’lehmer’,N) for N=100*[1:10].