function c = bisect1(a,b,f)
% BISECT1 slightly general implementation of bisection following
%    pp 76-78 of Kincaid&Cheney
% try
%   >> bisect1(0,1,@(x) cos(x)-x)
% compare bisect.m

u = feval(f,a);
v = feval(f,b);
e = b - a;

M = 50;

for k = 1:M
  e = e / 2.0;
  c = a + e;
  disp(c)
  w = feval(f,c);
  if sign(w) ~= sign(u)
    b = c;
    v = w;
  else
    a = c;
    u = w;
  end
end

