PHYCS 3730/6720 Lab Exercise

Reading and references:

Here we examine the power and inverse power methods with numpy. The answer file is Mylab12.txt.

We are looking for the eigenvalues and eigenvectors of the matrix

       3  1 -2  1
       1  8 -1  0
      -2 -1  3 -1       
       1  0 -1  8

Exercise 1. Finding the eigenvalues and eigenvectors using numpy

Set up the matrix (call it A, in Python, interactive mode. Find the eigenvalues and eigenvectors.

In your answer file, make a table showing each eigenvalue and the corresponding eigenvector.

Exercise 2. Power method

Use the power method for finding the largest eigenvalue and the corresponding eigenvector. Do this to four significant figures. For definiteness, start with the vector x = (1,1,1,1). Here are the steps:
  1. Multiply y = A x and print the result.
  2. Find the element of the vector y with the largest absolute value. Divide y by that element and call the result x. Note, this can be done by using the command x = y/y[1].
  3. Repeat steps 1 and 2, observing how the value of the largest element and the trial vector x converges. You may use a for loop to save steps. Does the eigenvector agree with the one found by in Exercise 1? (You may need to change the normalization of the vector to see agreement.)

In your answer file, show a few of your steps from the Python interactive session (including the for loop if you used it) and give your final answer for the eigenvector and eigenvalue.

Exercise 3. Inverse power method

Repeat the previous exercise, but use the inverse of the matrix instead to get the smallest (in magnitude) eigenvalue and corresponding eigenvector. (This is the method we discussed in class to get the eigenvalue closest to 0.)

Answer in the same way as in Exercise 2.