function y=newtonsys(f,dfdx,x,varargin) %NEWTONSYS Root finding, Newton method, systems of equations. % X=NEWTONSYS(F,DFDX,X0) attempts to find the solution of the nonlinear % system of equations F(X)=0 near X0 where DFDX is the derivative (Jacobian % matrix) of the function F using Newton method. % % X=NEWTONSYS(F,DFDX,X0,P1,P2,...) passes the parameters P1,P2,... to F. % Francisco J. Beron-Vera,2006/09/18 y=x+1; k=0; while norm(y-x)>eps*norm(y) k=k+1; if k>50 warning('Tolerance not satisfied.') break end y=x; x=x-dfdx(x,varargin{:})\f(x,varargin{:}); en