Can anybody help with this MatLab code for Inverse Power Method?

I tried to run this one, but I think there is wrong answer on the command line. Here is my answer. [z, mm] = Inv_Power(A, 10, 0.0001) iter m r z(1) z(2) z(3) z(4) 1.0000 -75.0275 128.3629 0.4472 0.4472 0.4472 0.4472 0.4472
2.0000 148.6814 0.0000 -0.4125 -0.8161 -0.2919 0.1661 0.2260
Inv Power Method has converged
mm =
0.0067
z =
-0.4125
-0.8161
-0.2919
0.1661
0.2260
mm =
0.0067
*Please run this code for matrix A until get an answer.*
*Here is matrix A* = [11 -8 6 -4 2
16 -13 12 -8 4
4 -4 5 0 0
-9 9 -9 12 -5
-6 6 -6 6 -1];
*Here is the Inverse Power Method code.*
function [z, mm] = Inv_Power(A, maxit,tol)
[n1,n2] = size(A);
L = eye(n1);
U = A;
for j = 1 : n1
for i = j+1 : n1
L(i, j) = U(i,j)/U(j,j);
U(i, : ) = U(i, : ) - L(i, j)*U(j, :);
end
end
w = ones(n1, 1);
disp(' iter m r z(1) z(2) z(3) z(4)')
for i = 1:maxit
z = w/norm(w);
w = LU_Solve(L, U, z);
m = z'*w;
r = norm(m*z - w);
out = [ i, m, r, z'];
disp(out)
if r < tol
disp('Inv Power Method has converged')
break
end
end
mm = 1/m

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Asked:

on 27 Oct 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!