My code works BUT I need to add 2 more things:
- output- a vector containing the sequence of estimates including the initial guess x0,
input- max iterations
function [ R, E ] = myNewton( f,df,x0,tol ) i = 1; while abs(f(x0)) >= tol R(i) = x0; E(i) = abs(f(x0)); i = i+1; x0 = x0 - f(x0)/df(x0); end if abs(f(x0)) < tol R(i) = x0; E(i) = abs(f(x0)); end end