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