%   secant9b.m -- solve f(x)=0 by the secant method
%   Written Sep 25, 2005 by Eric Olson for Mathematics 466
%
%   x=secant9b(phi,x,erel)

function x=secant9b(f,x1,x2,erel)
    f2=feval(f,x1);
    for n=1:3000
        f1=f2;
        f2=feval(f,x2);
        if abs(f2-f1)<=erel*f2
            break
        end
        x3=x2-f2*(x2-x1)/(f2-f1);
        x1=x2;
        x2=x3;
    end
    x=x2;
