
function [b]=ScdM(A,N)
    Q=ones(1,N)
    b=A*Q'
endfunction

function [x]=Solv(A,b)
   x=linsolve(A,-b)
endfunction

function [Er]=Erreur(N,x)
    Er=norm(ones(N,1)-(x))
endfunction
    
function [Jac]=Jacobi(k,A,N)
    
    D=diag(diag(A))
    L=tril(A)-D
    U=triu(A)-D
    b=A*ones(N,1)
     
     if k==0 then Jac=zeros(N,1)
        else Jac=-inv(D)*(L+U)*Jacobi(k-1,A,N)+inv(D)*b
    end
endfunction

function [i]=kJac(A,N,k)
     b=A*ones(N,1)
     i=0
     kJ=norm(A*Jacobi(i,A,N)-b,2)/norm(b,2)
     while kJ>10^-8 & k>i
         i=i+1 
         kJ=norm(A*Jacobi(i,A,N)-b,2)/norm(b,2)
     end
endfunction

function kJacobi=kJ(i,A,N)
     b=A*ones(N,1)
     kJacobi=norm(A*Jacobi(i,A,N)-b,2)/norm(b,2)    
endfunction

function [ErJ]=ErreurJ(i,A,N)
    ErJ=norm((ones(N,1))-(Jacobi(i,A,N)))
endfunction

function DErr=DErreur(ErJ,Er)
    DErr=ErJ/Er
endfunction

function [ibis]=kJacb(A,N,k)
     b=A*ones(N,1)
     ibis=0
     kJ=norm(A*Jacobi(ibis,A,N)-b,2)/norm(b,2)
     while kJ>10^-8 & k>ibis
         ibis=ibis+1 
         kJ=norm(A*Jacobi(ibis,A,N)-b,2)/norm(b,2)
     end
endfunction