function [lambda, x, iteration] = potenzmethode(A,n,x,epsilon);

err=1;
iteration = 0;
[r,index]=max(abs(x));
while err>epsilon
    x_old = x;
    r_old=r;
    index_old=index;
    
    if iteration >=1
        lambda_old=lambda;
    end
    
    x = A*x_old; 

    [r,index]=max(abs(x));
    
    if r==0
        error('Alle Komponenten von x sind 0!') ;
    else
        lambda = x(index_old)/x_old(index_old);
        x=x/x(index);
    end
    
    
    iteration = iteration + 1;
    
    if iteration >= 2 & lambda~=0
        err = abs(lambda-lambda_old);
    else 
        err = 1; 
    end
    
end