Skip to content

Instantly share code, notes, and snippets.

@hurutoriya
Created March 25, 2016 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hurutoriya/33e15829f02552a8ac13 to your computer and use it in GitHub Desktop.
Save hurutoriya/33e15829f02552a8ac13 to your computer and use it in GitHub Desktop.
Power Method
n = 5;
res = 10^(-13);
A = rand(n,n);
A = A'+A;
x = rand(n,1)
x_1 = A*x;
ite = 0;
while res < abs(norm(x_1)-norm(x))
ite = ite +1
x = x_1
x_1 = A*x;
x_1 = x_1/norm(x_1);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment