MATLAB Homework 2:

Due 20/12/2000

1. Write a MATLAB program that computes the eigenvalues and
eigenvectors of an arbitrary dimensional square matrix A.
Test your algorithm on a 3x3 example.

2. By using your code compute the eigenvalues of the following
two matrices and comment on the results:
A = diag([1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20])
B = A+randn(20,20)*0.00001
where randn is a built-in function of MATLAB.

3. Now find the eigenvalues of the following matrix
A = diag([1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]+randn(1,20)*0.00001)
by using:
(i) the code you wrote in part 2,
(ii) the matlab code for polynomial root finding on the characteristic equation of A.

Comment on the results.

4. For A = [ 1,2,3 ; 2,2,-3 ; 3,4,0 ; -1,0,6], and b = [0;2;1;0],
find the least squares solution to Ax=b
by using singular value decomposition routine svd.m.
Also find the span of the obtained singular vectors
and relate them to the column and row space of A.