function [res_newton, tot_iter] = newton(Func, Jacobian, p0, maxit, acc)

%  Newton gia tin epilish mh grammikwn systimatwn e3iswsewn 
%  Lysh tou grammikou systimatos J(X)S(X)=-F(X)

%Starting Evaluations
accur=0.5*10^(-acc);

stop=false;
k=0;
X0=p0;

res_newton = X0;

while (stop==false)
    k=k+1;
    F = feval(Func, X0);
    Jacob = feval(Jacobian, X0);
    Sp = -Jacob\F;

    Sp = Sp';
    X1 = X0 + Sp;
    
    if (norm(F,2)<=accur) || (norm(Sp,2)<=accur)
        stop=true;
    elseif (k >= maxit)  
        stop=true;
    end
    X0 = X1;
    
    res_newton = [res_newton ; X0];

end

tot_iter = k;

