% Secant method looks for a zero of function f using an
% inerative method, with first guess x=a, b.  It stops when |f(x_n)| < tol. 
%
% function root = secant(a,b,tol)

function root = secant(a,b,tol)

test = abs(f(a));
i = 0;
x0 = a;
x1 = b;
while test > tol
  x_new = x1-f(x1)*(x1-x0)/(f(x1)-f(x0));
  x0 = 	x1;
  x1 = x_new;
  test = abs(f(x_new));
  i = i+1;
end
i

root = x_new;