function x=reginewton(f,x0,erro,nmax)
%[x,n] = newton(f,x0,erro,nmax)
%        written by Reginaldo J. Santos on 22 April 2008
%                   DMat/ICEx/UFMG
var=findsym(f);
Jf=jacobian(f);
x0=x0(:);
x=x0;
n=0;
erron=erro+1;
% disp('    n         nerro     Xn');
while (erron>=erro)&(n<nmax)
    A=double(subs(Jf,var,x));
    b=-double(subs(f,var,x));
    b=b(:);
    dx=A\b;
    n=n+1
    erron=norm(dx);
    x=x+dx;
%    disp([n,erron,x']);
end
