function power_iter()
close all
A=2*rand(2,2)-1;
close all
%A = A*A';
%A=[1 -5;5, 1];
xnew = [1,1]';
xold = [sqrt(2),sqrt(2)]';
eig_max_old = 99;
change = 1;
z=[]
ii = 1;
while (change >= .0000001 & ii <= 500)
    xold = xnew/norm(xnew);
    z(:,ii) = xold;
    xnew = A*xold;
    hold on
    plot(z(1,ii),z(2,ii),'r*')
    hold off
  
    ii = ii+1;
    if (xold(1) ~= 0)
       eig_max_new = xnew(1)/xold(1);
   else
        eig_max_new = xnew(2)/xold(2);
    end
     %eig_max_new = norm(xnew);  
    change = abs(eig_max_new - eig_max_old);
    eig_max_old = eig_max_new;
    hold on
    quiver(0,0,xold(1),xold(2),'b')
      pause(0.01)
    quiver(0,0,xold(1),xold(2),'w')
    hold off
end
ii
eig_max_new
hold on
quiver(0,0,xold(1),xold(2),'b')
hold off
eig(A)