function z = secantELB(f,x0,x1)
% SECANTELB  Secant method by Ed L. Bueler.  Prints intermediate results.
%            *Not* an efficient or robust implementation.
% Good example:
%   >> f = @(x) x.^3 - 12 * x.^2 + 3 * x + 1
%   >> x = -5:0.01:15;  plot(x,f(x)),  grid on,  axis([-5 15 -20 20])  % locate roots
%   >> x = 0:0.001:1;   plot(x,f(x)),  grid on                         % closer view
%   >> secantELB(f,0.4,0.45)
% Bad example:
%   >> g = @(x) sin(x/2) - 1
%   >> secantELB(g,3,3.1)

while abs(x1-x0)/abs(x1) > 10*eps
  xnew = x1 - feval(f,x1) * (x1 - x0) / ( feval(f,x1) - feval(f,x0) )
  x0 = x1;
  x1 = xnew;
end
z = xnew;
