%   iter8a.m -- Iteratate until convergence to a relative tolerance
%   Written Sep 25, 2005 by Eric Olson for Mathematics 466
%
%   [x,xn]=iter8a(phi,x,erel)

function [x,xn]=iter8a(phi,x,erel)
    n=1;
    xn(n)=x;
    while n<3000
        xn(n+1)=feval(phi,xn(n));
        n=n+1;
        if abs(xn(n-1)-xn(n))<=erel*xn(n)
            break
        end
    end
    x=xn(n);
