> A = [3,0,0;0,2,0;0,0,2] A = 3 0 0 0 2 0 0 0 2 > B = rand(3,3) B = 0.9501 0.4860 0.4565 0.2311 0.8913 0.0185 0.6068 0.7621 0.8214 > A = inv(B)*A*B A = 3.5906 0.8136 0.7641 -0.3957 1.7976 -0.1901 -0.8079 -0.4133 1.6118 > eig(A) ans = 3.0000 2.0000 2.0000 > format compact > z = rand(3,1); perform the power method to find the largest eigenvalue. > for i=1:50, w = A*z; lambda(i) = w(1)/z(1); z = w/sqrt(sum(w.*w)); end here are the first 50 approximate eigenvalues. They're converging to 3. > lambda lambda = Columns 1 through 7 6.0773 4.0127 3.5048 3.2880 3.1752 3.1104 3.0710 Columns 8 through 14 3.0462 3.0303 3.0200 3.0133 3.0088 3.0059 3.0039 Columns 15 through 21 3.0026 3.0017 3.0012 3.0008 3.0005 3.0003 3.0002 Columns 22 through 28 3.0002 3.0001 3.0001 3.0000 3.0000 3.0000 3.0000 Columns 29 through 35 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 Columns 36 through 42 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 Columns 43 through 49 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 Column 50 3.0000 > format short e We wee that by the 50th step, the error is 1.8e-9. > lambda-3 ans = Columns 1 through 6 3.0773e+000 1.0127e+000 5.0475e-001 2.8804e-001 1.7520e-001 1.1036e-001 Columns 7 through 12 7.0961e-002 4.6214e-002 3.0342e-002 2.0026e-002 1.3262e-002 8.8023e-003 Columns 13 through 18 5.8511e-003 3.8931e-003 2.5920e-003 1.7265e-003 1.1504e-003 7.6661e-004 Columns 19 through 24 5.1095e-004 3.4057e-004 2.2702e-004 1.5134e-004 1.0089e-004 6.7255e-005 Columns 25 through 30 4.4836e-005 2.9890e-005 1.9927e-005 1.3284e-005 8.8561e-006 5.9041e-006 Columns 31 through 36 3.9360e-006 2.6240e-006 1.7493e-006 1.1662e-006 7.7749e-007 5.1832e-007 Columns 37 through 42 3.4555e-007 2.3037e-007 1.5358e-007 1.0239e-007 6.8257e-008 4.5504e-008 Columns 43 through 48 3.0336e-008 2.0224e-008 1.3483e-008 8.9885e-009 5.9924e-009 3.9949e-009 Columns 49 through 50 2.6633e-009 1.7755e-009 Now try a matrix with a smaller gap between the largest and the second largest eigenvalues. > A = [3,0,0;0,2.5,0;0,0,2] A = 3.0000e+000 0 0 0 2.5000e+000 0 0 0 2.0000e+000 > A = inv(B)*A*B > A = 3.5767e+000 7.6024e-001 7.6304e-001 -2.6005e-001 2.3207e+000 -1.7925e-001 -9.2359e-001 -8.5918e-001 1.6026e+000 > z = rand(3,1); > for i=1:50, w = A*z; lambda(i) = w(1)/z(1); z = w/sqrt(sum(w.*w)); end After 50 iterations, the error is larger... 5.2e-6 > lambda-3 ans = Columns 1 through 6 2.3500e+000 8.9128e-001 4.6630e-001 2.7497e-001 1.7244e-001 1.1227e-001 Columns 7 through 12 7.5010e-002 5.1113e-002 3.5411e-002 2.4901e-002 1.7762e-002 1.2846e-002 Columns 13 through 18 9.4195e-003 7.0009e-003 5.2724e-003 4.0211e-003 3.1036e-003 2.4219e-003 Columns 19 through 24 1.9089e-003 1.5180e-003 1.2165e-003 9.8146e-004 7.9637e-004 6.4931e-004 Columns 25 through 30 5.3154e-004 4.3658e-004 3.5957e-004 2.9681e-004 2.4546e-004 2.0329e-004 Columns 31 through 36 1.6857e-004 1.3991e-004 1.1622e-004 9.6601e-005 8.0335e-005 6.6835e-005 Columns 37 through 42 5.5622e-005 4.6302e-005 3.8552e-005 3.2105e-005 2.6740e-005 2.2273e-005 Columns 43 through 48 1.8555e-005 1.5458e-005 1.2879e-005 1.0730e-005 8.9405e-006 7.4496e-006 Columns 49 through 50 6.2074e-006 5.1725e-006 take the gap smaller still... > A = [3,0,0;0,2.9,0;0,0,2] A = 3.0000e+000 0 0 0 2.9000e+000 0 0 0 2.0000e+000 > A = inv(B)*A*B A = 3.5657e+000 7.1758e-001 7.6215e-001 -1.5153e-001 2.7392e+000 -1.7056e-001 -1.0161e+000 -1.2159e+000 1.5952e+000 > z = rand(3,1); > for i=1:50, w = A*z; lambda(i) = w(1)/z(1); z = w/sqrt(sum(w.*w)); end After 50 iterations, the error is larger still... 9.2e-4 > lambda-3 ans = Columns 1 through 6 2.7037e+000 9.5100e-001 4.8356e-001 2.7942e-001 1.7200e-001 1.0990e-001 Columns 7 through 12 7.2034e-002 4.8177e-002 3.2828e-002 2.2812e-002 1.6210e-002 1.1823e-002 Columns 13 through 18 8.8849e-003 6.9024e-003 5.5522e-003 4.6220e-003 3.9717e-003 3.5084e-003 Columns 19 through 24 3.1706e-003 2.9172e-003 2.7210e-003 2.5638e-003 2.4335e-003 2.3221e-003 Columns 25 through 30 2.2240e-003 2.1356e-003 2.0546e-003 1.9791e-003 1.9082e-003 1.8409e-003 Columns 31 through 36 1.7768e-003 1.7154e-003 1.6566e-003 1.6000e-003 1.5455e-003 1.4930e-003 Columns 37 through 42 1.4424e-003 1.3935e-003 1.3464e-003 1.3009e-003 1.2569e-003 1.2145e-003 Columns 43 through 48 1.1735e-003 1.1340e-003 1.0958e-003 1.0588e-003 1.0232e-003 9.8873e-004 Columns 49 through 50 9.5546e-004 9.2331e-004