%
%  A while loop for the Secant method.
%  Method requires two initial guesses
%  x(1)and x(2). Code will stop iterations
%  if the difference between susequent
%  x(i) values is too small x(i+1)-x(i)<tolerance
% 
%
clear x
tolerance=10^(-8);
x(1)=2;
x(2)=1;
i=2;
while abs(x(i)-x(i-1)) > tolerance 
     x(i+1)=x(i)-f(x(i)).*(x(i)-x(i-1))./(f(x(i))-f(x(i-1)));
     i=i+1;
end;
%
% Want double precision output to 
% see the rapid convergence rate.
%
% Also, x is a row vector. To output
% it as a column vector take its transpose
% Here that is "  x'  "
%
format long
x'




