Professional Documents
Culture Documents
NewtonSolution (Matlab Code)
NewtonSolution (Matlab Code)
% Part C
% define variables
x0 = 1.2;
i = 0;
n = 100;
emax = 1E-6;
xold = x0;
%Update iteration
i = i + 1;
xold = xnew;
[fx_xold, fxprime_xold] = f_a2q1c(xold); %get function value at xold
end
if i<n
'Root is'
xold
'Number of iterations'
i
else
'No convergence'
end
%--------------------------------------------------------
% modified newton when multiplicity is known
ex0 = 1.2;
j = 0;
z = 100;
m=2;
emax = 1E-6;
xold = ex0;
end
if j<z
'Root is'
xold
'Number of iterations'
j
else
'No convergence'
end
%-----------------------------------
end
%-----------------------------------