%
% esempio del metodo di bisezione
%
clear all
format long
a=0
b=1
f=@(x)x^3-3*x+1
h=@(x)0
fplot(f,[0,1])
hold on
fplot(h,[0,1])
tol=10^(-5)
n=0
while b-a> tol
    clf
    n=n+1;
    p=(a+b)/2;
    if f(a)*f(p)<0, b=p; else a=p; end
    [n,a,b]
    fplot(f,[0,1])
    hold on
    fplot(h,[0,1])
    plot(a,0,'.',b,0,'.')
    pause
end
