%newton method iterant
close all
clear all
clc
%input initial guess
xkp1=input('initial guess at root ?');
tol = 1.E-10;
%in loop, xk is previous
% xkp1 is next value of x
xk = xkp1 + 10*tol;
while (abs(xkp1-xk)>tol)
    xk=xkp1;
   xkp1=xk-demfun2(xk)/derivfun2(xk);
   fprintf('\nxkp1= %14.10f xk = %14.10f',xkp1,xk)
end