Bisection Method

% Bisection Method applied to user defined f(x)

% Date: Jan 27, 1999

% by Yuri V Lvov

% The Bisection method is relatively slow compared to the Secant or Newton's

% method.

x = []; i=1;

a = .9; % initial guess

b = 10000; % initial guess

while (abs(a-b)>.0001),

mid = (a+b)/2;

if (f(a)*f(mid) >0),

a = mid;

else

b = mid;

end

disp(i);disp(' mid=');disp(mid);i=i+1;

end