You can do the above example and other examples using Matlab. Here are some commands which will do this. It is done here for a 3 × 3 matrix but you adapt for any size.

eye(3) signifies the 3 × 3 identity. It is less trouble to write this.
Note how the “while loop” is limited to 1000 iterations. That way it won’t go on forever if there is something wrong. This asks for the eigenvalue closest to b = i. When Matlab stalls, to get it to quit, you type control c. The last line checks the answer and the line with k tells the number of iterations used. Also, the funny notation [M,I]=max(abs(w)); T=w(I); gets it to pick out the entry which has largest absolute value w(I) and keep that entry unchanged. The above iteration finds the eigenvalue closest to i along with the corresponding eigenvector. When the procedure does not work well for b real, you might imagine that there are complex eigenvalues and so, since the above procedure is going to give you real approximations, it can’t find the complex eigenvalues. Thus you should take b to be complex as done above.
If you have Matlab work the above iteration, you get the following for the eigenvector eigenvalue and number of iterations, and error .

In fact, this eigenvector is exactly right as is the eigenvalue 1 + i.
Thus this method will find eigenvalues real or complex along with an eigenvector associated with the eigenvalue. Note that the characteristic polynomial of the above matrix is λ^{3} − 5λ^{2} + 8λ − 6 and the above finds a complex root to this polynomial. More generally, if you have a polynomial λ^{n} + a_{n−1}λ^{n−1} +

You could use this or the earlier companion matrix described in the material on the rational canonical form. Thus this method is capable of finding roots to a polynomial equation which are close to a given complex number. Of course there is a problem with determining which number you should pick. A way to determine this will be discussed later. It involves something called the QR algorithm.
Example 16.2.1 Find the eigenvalue of A =
We use the algorithm described above.

This yields the following after 8 iterations.

for the eigenvector and eigenvalue. In fact, this is exactly correct.
Example 16.2.2 Consider the symmetric matrix A =
Since A is symmetric, it follows it has three real eigenvalues which are solutions to

Note that
There is an easy to use trick which will eliminate some of the fuss and bother in using the shifted inverse power method. If you have

then multiplying through by
Example 16.2.3 Find the eigenvalue near −1.2 along with an eigenvector.

This is only a 3×3 matrix and so it is not hard to estimate the eigenvalues. Just get the characteristic equation, graph it using a calculator and zoom in to find the eigenvalues. If you do this, you find there is an eigenvalue near −1.2, one near −.4, and one near 5.5. (The characteristic equation is 2 + 8λ + 4λ^{2} − λ^{3} = 0.) Of course we have no idea what the eigenvectors are.
Lets first try to find the eigenvector and an approximation for the eigenvalue near −1.2. In this case, let α = −1.2. Then

Then

How close is this to being an eigenvector?


For all practical purposes, this has found the eigenvector and eigenvalue of −1.2185.