No BSD License  

Highlights from
Numerical Methods using Matlab, 2e

image thumbnail
from Numerical Methods using Matlab, 2e by John Penny
Companion Software

[res, it]=fnewton(func,dfunc,x,tol)
function [res, it]=fnewton(func,dfunc,x,tol)
% Finds a root of f(x) = 0 using Newton's method.
%
% Example call: [res, it]=fnewton(func,dfunc,x,tol)
% The user defined function func is the function f(x),
% The user defined function dfunc is df/dx.
% x is an initial starting value, tol is required accuracy.
%
it=0; x0=x;
d=feval(func,x0)/feval(dfunc,x0);
while abs(d)>tol
  x1=x0-d;
  it=it+1;
  x0=x1;
  d=feval(func,x0)/feval(dfunc,x0);
end;
res=x0;

Contact us at files@mathworks.com