0

I have a question concerning the Newton Algorithm in MATLAB.

The algorithm should be capable of performing a two-sided approximation technique for the Jacobian Matrix in case that there is no analytical Jacobian provided.

function [x,fx,ef] = newton(f,x,cc)

% convergence criteria
tole = cc(1,1); told = cc(2,1); maxiter = cc(3,1);

% newton algorithm
ef = 0;
for j = 1:maxiter
   [fx,dfx] = f(x);
   xp = x − dfx\fx;
   D = (norm(x−xp)<=tole*(1+norm(xp)) && norm(fx)<=told);
   if D == 1;
      ef = 1; break;
   else
      x = xp;
   end
end
πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
  • I don't get what the question is sorry. Is there something wrong with your current code? – Benoit_11 Oct 31 '14 at 14:44
  • Thank you! It needs to be extended and I do not know how to implement it. – antonio Oct 31 '14 at 14:46
  • You can switch between the case the Jacobian is provided or not using `nargout('f')`. In the case the Jacobian is not provided use any of the various numerical approximation methods e.g. http://www.mathworks.com/matlabcentral/fileexchange/13490-adaptive-robust-numerical-differentiation – matheburg Oct 31 '14 at 14:58

0 Answers0