Please also provide the cords for MATLAB Implement the following algorithm, give
ID: 2965857 • Letter: P
Question
Please also provide the cords for MATLAB
Implement the following algorithm, given A and so, yk = Axk rk = yk 2/ xk 2 xk + 1 = yk/yk/2 Where y 2 denotes its 2-norm of the vector y. Note that x0,x1,... and xk form a sequence of vectors. The subscript here refers the position in the sequence. This algorithm computes iteratively the largest entry(in absolute value) of an upper triangular matrix. For general matrix, this computes the largest eigenpair of a matrix(we will discuss about it in later weeks). Use the matrix and initial vector, A = -5/3/1/0/4/1/0/0/-2/ x0 = 1/1/1 Output the vector X20, the vector y20 and thee ratio r20- You should notice that, the vector x approximate the vector [ 1 0 0 ]T.Explanation / Answer
A=[-5 3 -1;0 4 1;0 0 -2];
n=3; % number of steps
y=zeros(3,1,n);
r=zeros(1,n);
x=zeros(3,1,n);
x(:,:,1)=[1;1;1];
for i=1:n
y(:,:,i)=A*x(:,:,i);
r(i)=norm(y(:,:,i),2)/norm(x(:,:,i),2);
x(:,:,i+1)=y(:,:,i)./norm(y(:,:,i),2);
end
fprintf('x20=%f %f %f ',x(:,:,n));
fprintf('y20=%f %f %f ',y(:,:,n));
fprintf('r20= %f ',r(1,n));
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.