function [xnew,its]=newt(f,fp,xold,tol) %NEWT Newton's method % [xnew,its]=newt(f,fp,xold,tol) uses Newton's method for rootfinding. % It returns a root, xnew, of f(x) (with derivative given by function fp(x)) % using a starting guess xold. The stopping criteria is |f(x)|tol xnew=xold-fxold/fp(xold); xold=xnew; fxold=f(xold); its=its+1; end xnew=xold;