ASSIGNMENT 3
Question 1
give two commands
>rand("state",student_number);
>rand(1)
Run own output and paste your output here
Question 2
function x1 = powermethod(A, iter)
[m,n] = size(A);
x1=rand(n,1);
for k = 1 : iter
xcap = A*x1;
xnorm = norm(xcap,2);
x1 = xcap/norm(xcap,2);
end;
end
%A matrix
A = [2.781344 -1.921334 0.493612 1.367198 -1.014289; 0.015050 -0.205731 0.903377 1.780261 -
0.824057; -0.087144 0.606003 2.977860 -0.140473 -0.750938; 0.212440 -2.477599 0.980236
4.233562 -1.207581; -0.136646 -1.168924 0.453692 0.915245 1.712964 ];
% power method using Eigen values
x1 = powermethod(A,100);
eigVal_power_A = (A*x1)./x1;
% eigenvalues and eien vector values A*V = V*D
[V,D] = eig(A)
, Output
V =
0.4203 0.4864 -0.1081 0.3310 -0.4399
0.6126 0.2587 -0.4846 0.4498 0.2630
0.0040 0.4096 -0.0449 0.4752 0.8173
0.5710 0.3920 -0.8295 0.6533 0.1595
0.3493 0.6124 -0.2519 0.1884 0.2094
D =
1.0000 0 0 0 0
0 2.0000 0 0 0
0 0 2.5000 0 0
0 0 0 3.0000 0
0 0 0 0 3.0000
Question 3
function x1 = powermethod(A, iter)
[m,n] = size(A);
x1=rand(n,1);
for k = 1 : iter
xcap = A*x1;
xnorm = norm(xcap,2);
x1 = xcap/norm(xcap,2);
end;
end
%A matrix
A = [-1.6731385 -3.6381454 -1.8272855 -2.7022868; -1.7080530 -0.0039461 0.1019678 -1.3595453;
2.4426950 3.4321965 3.8982919 2.1372124; 5.7672696 5.4815125 1.3344020 6.2787928 ];
% power method using Eigen values
x1 = powermethod(A,100);
eigVal_power_A = (A*x1)./x1;