function [x,ierr] = newton(f, fd, x0, epsi, delta, maxf, maxstep) % Newton's method for evaluating a root of the function % f whose derivative is given in fd. % % calling sequence: [x,ierr] = newton(@f, @fd, x0, epsi, delta, maxf, maxstep) % % f = name of the matlab function that evaluates f % fd = name of the matlab function that evaluates f' % x0 = initial guess for the root x % epsi = terminate (with ierr=0) if two successive x values % differ by less than this amount % delta = terminate (with ierr=0) if |f| drops below this value % maxf = maximum number of iterations; terminate with ierr=2 if exceeded % maxstep = terminate (with ierr=1) if step is longer than this value % % the routine prints out iteration number, x, and f at each iteration %