clear all;

a=1; b=2; func='x^3+2*x^2+10*x-20'; kmax=50; toll=10^-10;

format long
k=0;
while k<kmax & b-a>toll
   k=k+1
   x=a+(b-a)/2
      fx=eval(func);
   if fx>0 
      b=x;
   else
      a=x;
   end;
end;

format short


