function L=qr_it(A);
% QR_IT Given an (n x n) matrix A with real eigenvalues.
% This function are using QR iterations in order to calculate the
% n-eigenvalues l_i for all i=1,2,...,n stored on the diagonal of L
% on output.
% L=qr_it(A)
% ON INPUT
% A - An (n x n) matrix with real eigenvalues
% ON OUTPUT
% L - An (n x n) diagonal matrix similar to A, i.e. with the n-eigenvalues
%     of A on the diagonal.

max_it=10;
for i=1:max_it
    [Q,R]=qr(A); 
    A=R*Q;
end
L=A;