Code covered by the BSD License  

Highlights from
Numerical Methods Using MATLAB, 3e

image thumbnail

Numerical Methods Using MATLAB, 3e

by

 

20 Aug 2002 (Updated )

Companion Software

[P,iter,err]=newdim(F,JF,P,delta,epsilon,max1)
function [P,iter,err]=newdim(F,JF,P,delta,epsilon,max1)

%Input-F is the system saved as the M-file F.m
%     -JF is the Jacobian of F saved as the M-file JF.M
%     -P is the inital approximation to the solution
%     -delta is the tolerance for P
%     -epsilon is the tolerance for F(P)
%     -max1 is the maximum number of iterations
%Output-P is the approximation to the solution
%      -iter is the number of iterations required
%      -err is the error estimate for P

% NUMERICAL METHODS: MATLAB Programs
%(c) 1999 by John H. Mathews and Kurtis D. Fink
%To accompany the textbook:
%NUMERICAL METHODS Using MATLAB,
%by John H. Mathews and Kurtis D. Fink
%ISBN 0-13-270042-5, (c) 1999
%PRENTICE HALL, INC.
%Upper Saddle River, NJ 07458

Y=feval(F,P);

for k=1:max1
   J=feval(JF,P);
   Q=P-(J\Y')';
   Z=feval(F,Q);
   err=norm(Q-P);
   relerr=err/(norm(Q)+eps);
   P=Q;
   Y=Z;
   iter=k;
   if (err<delta)|(relerr<delta)|(abs(Y)<epsilon)
     break
   end
end



Contact us