352 CHAPTER 15. NUMERICAL METHODS, EIGENVALUES

4. When the scaling factors, Sk+1 are not changing much and the uk are not changingmuch, find the approximation to the eigenvalue by solving

Sk+1 =1

λ −α

for λ . The eigenvector is approximated by uk+1.

5. Check your work by multiplying by the original matrix to see how well what youhave found works.

Also note that this is just the power method applied to (A−λ I)−1 . The eigenvalue youwant is the one which makes 1

λ−αas large as possible for all λ ∈ σ (A). This is because

making λ −α small is the same as making (λ −α)−1 large.

15.3 Automation With MATLABYou can do the above example and other examples using MATLAB. Here are some com-mands which will do this. It is done here for a 3×3 matrix but you adapt for any size.

a=[5 -8 6;1 0 0;0 1 0]; b=i; F=inv(a-b*eye(3));S=1; u=[1;1;1]; d=1; k=1;while d > .00001 & k <1000w=F*u; [M,I]=max(abs(w)); T=w(I); u=w/T;d=abs(T-S); S=T; k=k+1;endub+1/Tka*u-(b+1/T)*u

Note how the “while loop” is limited to 1000 iterations. That way it won’t go on foreverif there is something wrong. This asks for the eigenvalue closest to b = i. When MATLABstalls, to get it to quit, you type control c. The last line checks the answer and the linewith 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 thatentry unchanged. The above iteration finds the eigenvalue closest to i along with the cor-responding eigenvector. When the procedure does not work well for b real, you mightimagine that there are complex eigenvalues and so, since the above procedure is going togive you real approximations, it can’t find the complex eigenvalues. Thus you should takeb to be complex as done above.

If you have MATLAB work the above iteration, you get the following for the eigenvec-tor eigenvalue and number of iterations, and error . 1

.5− .5i−.5i

 , 1+ i, k = 18, 10−5

 0−0.1321+0.1862i−0.1325+0.1863i

