Docsity

Math Assignment 3: Solving Least Squares & Analyzing Matrix Exponentials (Math 477/577), Assignments of Linear Algebra

Toggle sidebar
bg1
Math 477/577 Computer Assignment 3 Charles Tier
For each question, please submit the Matlab code along with an execution of the code.
1. For this question let m= 50 and n= 12. Define tas an m-vector consisting of a linearly
space grid from 0 to 1 using MATLAB’s linspace command. Using MATLAB’s vander
and fliplr, define an m×nmatrix Afor the least squares problems of fitting the grid by a
polynomial of degree n−1. Let bbe the function cos(4t)evaluated on the grid. Calculate
and print (to 16 digit precision) the least squares solution xby the following 5 methods:
(a) Formation and solution by the normal equations using MATLAB’s \command.
(b) QR factorization computed using a routine mgs that you must write that uses the mod-
ified Gram-Schmidt.
(c) QR factorization using MATLAB’s qr.
(d) x=A\b.
(e) SVD using MATLAB’s svd.
You should produce 5 table of twelve coefficients. In each list, use a red pen to circle the
digits that appear to be incorrect due to rounding error. Explain the differences.
2. Let Aby a 10 ×10 random matrix with entries drawn from the standard normal distribution
minus twice the identity. Write a program to plot ketAk2for t∈[0,2] on a log scale. Com-
pare the result to the straight line etα(A)where α(A) = max <(λj)is the spectral abscissa
of A. Run the program for ten random matrices Aand discuss the results. What property of
a matrix leads to the graph of ketAk2that is oscillatory as t→ ∞?
Hints: The definition of the matrix exponential is
etA =
∞
X
k=0
Aktk
k!.
Use randm and expm to deal with normally distributed random numbers and matrix expo-
nentials, respectively.

Partial preview of the text

Download Math Assignment 3: Solving Least Squares & Analyzing Matrix Exponentials (Math 477/577) and more Assignments Linear Algebra in PDF only on Docsity!

Math 477/577 Computer Assignment 3 Charles Tier

For each question, please submit the Matlab code along with an execution of the code.

  1. For this question let m = 50 and n = 12. Define t as an m-vector consisting of a linearly space grid from 0 to 1 using MATLAB’s linspace command. Using MATLAB’s vander and fliplr, define an m × n matrix A for the least squares problems of fitting the grid by a polynomial of degree n − 1. Let b be the function cos(4t) evaluated on the grid. Calculate and print (to 16 digit precision) the least squares solution x by the following 5 methods:

(a) Formation and solution by the normal equations using MATLAB’s \ command. (b) QR factorization computed using a routine mgs that you must write that uses the mod- ified Gram-Schmidt. (c) QR factorization using MATLAB’s qr. (d) x = A\b. (e) SVD using MATLAB’s svd.

You should produce 5 table of twelve coefficients. In each list, use a red pen to circle the digits that appear to be incorrect due to rounding error. Explain the differences.

  1. Let A by a 10 × 10 random matrix with entries drawn from the standard normal distribution minus twice the identity. Write a program to plot ‖etA‖ 2 for t ∈ [0, 2] on a log scale. Com- pare the result to the straight line etα(A)^ where α(A) = max <(λj ) is the spectral abscissa of A. Run the program for ten random matrices A and discuss the results. What property of a matrix leads to the graph of ‖etA‖ 2 that is oscillatory as t → ∞? Hints: The definition of the matrix exponential is

etA^ =

∑^ ∞

k=

Ak^ t

k k!.

Use randm and expm to deal with normally distributed random numbers and matrix expo- nentials, respectively.