function [x,flag]=bisezione(fun,a,b,toll)
flag=0;
fa=fun(a); fb=fun(b);
if abs(fa) < eps
  x=a; return
end
if abs(fb) < eps
  x=b;  return
end
if fa*fb >0
  x='Error'; flag=1; return
end
x=(a+b)/2;
err=(b-a)/2;
while err > toll
  fx=fun(x);
  if abs(fx) < eps  return, end    
  if fa*fx < 0
    b=x; 
  else
    a=x; fa=fx;
  end
  x=(a+b)/2;
  err=err/2;
end




