function   [x,X]=newt101(F,JF,x0,Nmax,TOL);
%%function   [x,X]=newt101(F,JF,x0,Nmax,TOL);
%%  An implementation of Algorithm 10.1 in Burden Faires
%%  INPUT
%%    F - string containing name of the m-file that defines the function
%%        F to solve F(x)=0 (output is the column vector of values of F)
%%    JF - string containing the name of the m-file that defines the 
%%         Jacobian of the function F (output is the matrix of values)
%%    x0 - initial guess as a column vector
%%    Nmax - maximum number of iterations (default is 20)
%%    TOL - stopping criterion norm(x_k-x_k-1)<TOL (default is .0001)
%% OUTPUT
%%    x - approximate solution as a column vector
%%    X - matrix of successive approximate solutions as rows

if nargin< 5
   TOL=.0001;
end;
if nargin < 4;
Nmax=20;
end;
x=x0;X=[x'];
k=1;
FLAG=0;
while (k<=Nmax & FLAG==0)
    Fx=feval(F,x);
    Jx=feval(JF,x);
    %%y=Jx\(-Fx);%% Let Matlab solve the system 
    y=gescplu(Jx,-Fx); 
    x=x+y; X=[X;x'];
    if norm(y,inf)<TOL;
      fprintf('tolerence achieved')
      FLAG=1;
    end;
    k=k+1;
end;
if FLAG==0;
  fprintf( 'maximum number of iterations, %g is exceeded\n',Nmax)
end;
