% One dimensional Newton code % User must provide an inline function for f and another % for f', called df. x = input('enter the starting value x0 ') format compact disp(' iterate x f(x) est. error ') for n = 0:5 s = f(x)/df(x); sprintf(' %2d %2.10f %2.10f % 2.10f \n', n,x,f(x),s) x = x-s; end