% Secant Method to Solve f(x)=0, for user supplied f(x)
% Date: October 16,2002
% by Yuri V Lvov
format long;
x=[];x(1)=1;x(2)=2;
tolerance=.001;
i=3;
while (abs(x(i-1)-x(i-2))>tolerance),
x(i)=(x(i-1)- f(x(i-1))*(x(i-1)-x(i-2))/(f(x(i-1))-f(x(i-2))));
disp(i);disp(x(i));disp(' ');
i=i+1;
end