function [x,counter] = NewtonSolve(f,Df,x0,atol)

  if nargin<4 atol = 1e-10; end% if;
  maxit = 20; counter = 0; xOld = x0;
  x = xOld - feval(Df,xOld)\feval(f,xOld);
  while ((counter<=maxit) && (norm(xOld-x)>atol))
    xOld  = x;
    x = xOld-feval(Df,xOld)\feval(f,xOld);
    counter = counter+1;
  end%while
 end%function
