function [x it]=MyJOR(A,y,TOL)

N=length(y);
xalt=0.5*ones(N,1);
Res = norm(y,2);
itmax = 10000;
it=0;

while Res > TOL & it < itmax
    for i=1:N
        summ=0;
        for j=1:N
            if j~=i
                summ = summ + A(i,j)*xalt(j);
            end
        end
        x(i) = (y(i)-summ)/A(i,i);
    end
    Res = norm(A*x'-y,2);
    xalt = x;
    it = it+1;
    fprintf('Res (JOR) = %.2e nach %4d Iterationen\n',norm(A*x'-y,2),it);
    x
end

FixNorm(A);

end


function FixNorm(A)

%  T=M^(-1)*N, M=diag(A), N=M-A

M = diag(diag(A)); 
N = M-A;
T = inv(M)*N;

n1 = norm(T,1);
n2 = norm(T,2);
n3 = norm(T,Inf);

fprintf('||T||_1   = %.2e\n||T||_2   = %.2e\n||T||_inf = %.2e\n',n1,n2,n3);

end
