%   bisect5d.m -- Solve f(x)=0 on [a,b] to machine precision
%   Written Sep 14, 2005 by Eric Olson for Mathematics 466
%
%   For more information see the lecture notes at
%   http://fractal.math.unr.edu/~ejolson/466/notes/lect06.html

function x=bisect5d(f,a,b)
    fa=feval(f,a);
    fb=feval(f,b);
    if fa*fb>=0 || b<=a
        disp('Not a good initial bracket!');
    end
    c=(a+b)/2;
    while c ~= a && c ~= b
        fc=feval(f,c);
        if fc==0.0
            x=c;
            return
        end
        if fc*fa>0
            a=c;
        else
            b=c;
        end
        c=(a+b)/2;
    end
    x=(a+b)/2;
