I need help with the coding solution. I can do it but I am not sure about my ans
ID: 2248767 • Letter: I
Question
I need help with the coding solution. I can do it but I am not sure about my answer. pls do it and I will gladly rate.
Explanation / Answer
1. the code is given below with solutions
clc
clear
A = [2 8 10; 8 4 5; 10 5 7];
V1=[1; 1; 1]; % intitial vector
x1=A*V1; % zeroth iteration
[val] = max(x1);
y1 = x1*(1/val);
x2=A*y1; % first iteration
[val1] = max(x2);
y2 = x1*(1/val1);
loopcount=1;
while abs((val1-val)/val1)>0.001
val=val1;
x2=A*y2;
[val1] = max(x2);
y2 = x2*(1/val1);
loopcount=loopcount+1;
end
display(val1); % converged value of dominant eigan value
display(y2); % corresponsing eigan vector
display(loopcount); % how may iterations to converge excluding 0th iteration
Solutions are
val1 = 19.8895
y2 =
0.9033
0.7698
1.0000
loopcount = 4