### Section 8.7

Problems 6, 8, 11b, 12e, 14, 15

### Extra Problem

Choose 10 random values, "eig_true = rand(10,1)". Use these to define a diagonal matrix D. Now pick a random 10x10 matrix U, "U = rand(10,10)". Using U and D, define a matrix A whose eigenvalues are those of eig_true.

Ask matlab for the eigenvalues of A, "eig_matlab = eig(A)".
You want to compare them so you want to sort them in ascending order. Do this with "eig_true = eig_true'; eig_true = sort(eig_true); eig_matlab = eig_matlab'; eig_matlab = sort(eig_matlab);" Since sort will sort a row vector and at the moment eig_true is a column vector. The prime "'" gives the transpose, and the transpose of a column is a row.

Now use the power method to find the two largest eigenvalues of A. Think of some intelligent way to do the iteration until you've reached a small error. (Explain how you did it and how many iterates it took for each eigenvalue to reach that error.)
Compare your eigenvalues to the true eigenvalues. Compare matlab's eigenvalues to the true eigenvalues. Compare your eigenvectors to the true eigenvectors (you do know them exactly if you know where to look!).

Now repeat the problem with personally chosen eigenvalues. How can you choose them to make the errors smaller? How can you choose them to make the errors larger?

If something didn't go according to plan, can you figure out what happened?