We're going to find the largest eigenvalue and eigenvector for the matrix I did in class. Do this using the power method. > A = [ 1,3;3,4]; Choose a random first guess: > z = rand(2,1) z = 0.9501 0.2311 Apply the matrix to z_0. This gives us w_1. > w = A*z w = 1.6435 3.7749 Define z_1 by making w_1 of unit length: > z = w/sqrt(sum(w.*w)) z = 0.3992 0.9169 Apply the matrix to z_1. This gives us w_2. > w = A*z w = 3.1498 4.8650 find the approximate eigenvalue using the first component of w_2 and z_1 > w(1)/z(1) ans = 7.8905 find the approximate eigenvalue using the second component of w_2 and z_1 > w(2)/z(2) ans = 5.3061 They're not very close. Let's keep going. Define z_2 by making w_2 of unit length: > z = w/sqrt(sum(w.*w)) z = 0.5435 0.8394 Apply the matrix to z_2. This gives us w_3. > w = A*z w = 3.0618 4.9881 find the approximate eigenvalue using the first component of w_2 and z_1 > w(1)/z(1) ans = 5.6337 find the approximate eigenvalue using the second component of w_2 and z_1 > w(2)/z(2) ans = 5.9423 They're closer... Define z_3 by making w_3 of unit length: > z = w/sqrt(sum(w.*w)) z = 0.5231 0.8523 Apply the matrix to z_2. This gives us w_4. > w = A*z w = 3.0799 4.9784 find the approximate eigenvalue using the first component of w_2 and z_1 > w(1)/z(1) ans = 5.8875 find the approximate eigenvalue using the second component of w_2 and z_1 > w(2)/z(2) ans = 5.8414 They're closer still... Now I'll do 100 applications and will end up with w_105 and z_104 (or something) > for i=1:100, w = A*z; z = w/sqrt(sum(w.*w)); end > w = A*z w = 3.0777 4.9798 > format long e find the approximate eigenvalue using the first component of w_2 and z_1 > w(1)/z(1) ans = 5.854101966249684e+000 find the approximate eigenvalue using the second component of w_2 and z_1 > w(2)/z(2) ans = 5.854101966249685e+000 What's the difference? > w(1)/z(1)-w(2)/z(2) ans = -8.881784197001252e-016 It's at round-off. Compare it to the exact eigenvalue: > (5+3*sqrt(5))/2 ans = 5.854101966249685e+000 Now let's do another example. > A = rand(10,10); z = rand(10,1); This time, I'll just print out the first 20 approximations of the largest eigenvalue. I'll use the first component of z and w to define those approximations... > for i=1:20, w = A*z; w(1)/z(1), z = w/sqrt(sum(w.*w)); end ans = 6.051586826088908e+000 ans = 5.435530397147399e+000 ans = 5.311031263643748e+000 ans = 5.342101733909655e+000 ans = 5.333892658002270e+000 ans = 5.333979763866569e+000 ans = 5.333843519358664e+000 ans = 5.333860028497632e+000 ans = 5.333860588474614e+000 ans = 5.333860903524015e+000 ans = 5.333860860194060e+000 ans = 5.333860851754611e+000 ans = 5.333860850631273e+000 ans = 5.333860850680542e+000 ans = 5.333860850725885e+000 ans = 5.333860850729825e+000 ans = 5.333860850729944e+000 ans = 5.333860850729725e+000 ans = 5.333860850729706e+000 ans = 5.333860850729705e+000 After 20 iterations, we've converged to the level of round-off...