Using Matlab Carry out 50 steps of the power method for the
Using Matlab,
Carry out 50 steps of the power method for the matrix A = [2 -1 0 3 1 -1 1 1 0 2 1 -2 1 0 1 1]with X_0 = [1, 1, 0, 2]. Give your estimate for the dominant eigenvalue lambda from x: = X_49 and y: = y_49 = AX_49 via lambda = lambda = y_i/x_i where |x_i| = max_j |x_j|.Solution
code:
function [m,y]=power_method(A,x,steps)
% A input matrix
%x initial vector x0
% steps number of steps
% y_final normalized eigen vector
m=0;
n=length(x);
y=x;
total_steps=steps;
i=0;
while(i~=total_steps)
mold = m;
y_old=y;
y=A*y;
m=max(y);
y=y/m;
i=i+1;
end
end
output
>> A
A =
2 -1 0 3
1 -1 1 1
0 2 1 -2
1 0 1 1
>> x
x =
1
1
0
2
>> steps
steps =
50
>> [m y]=power_method(A,x,steps)
m =
3
y =
1.0000
0.3333
-0.1111
0.4444
>>
![Using Matlab, Carry out 50 steps of the power method for the matrix A = [2 -1 0 3 1 -1 1 1 0 2 1 -2 1 0 1 1]with X_0 = [1, 1, 0, 2]. Give your estimate for the Using Matlab, Carry out 50 steps of the power method for the matrix A = [2 -1 0 3 1 -1 1 1 0 2 1 -2 1 0 1 1]with X_0 = [1, 1, 0, 2]. Give your estimate for the](/WebImages/38/using-matlab-carry-out-50-steps-of-the-power-method-for-the-1114030-1761591345-0.webp)
![Using Matlab, Carry out 50 steps of the power method for the matrix A = [2 -1 0 3 1 -1 1 1 0 2 1 -2 1 0 1 1]with X_0 = [1, 1, 0, 2]. Give your estimate for the Using Matlab, Carry out 50 steps of the power method for the matrix A = [2 -1 0 3 1 -1 1 1 0 2 1 -2 1 0 1 1]with X_0 = [1, 1, 0, 2]. Give your estimate for the](/WebImages/38/using-matlab-carry-out-50-steps-of-the-power-method-for-the-1114030-1761591345-1.webp)