clear all;
%x=2; func='x^3+2*x^2+10*x-20'; funcder='3*x^2+4*x+10'; kmax=20; toll=10^-10;
x=2; func='x^3'; funcder='3*x^2'; kmax=50; toll=10^-10;

format long
err=toll+1;
k=0;
while k<kmax & err>toll
   k=k+1
   xold=x;
   x=x-eval(func)/eval(funcder)
   err=abs(x-xold);
end;

format short


