function NewtonF1(x,fcn,tol)
% Newton iteration in 1D

dx=1; result=[]; loop=0;
while abs(dx)> tol;
    [fx, fp]=feval(fcn,x);  
    % fcn returns the function & it's derivative at x
%    fx=x*x-4*sin(x);fp=2*x-4*cos(x);
    dx=-fx/fp;
    result=[result; [loop x fx fp dx]];
    x=x+dx;
    loop=loop+1;
end;


