% define your function f=inline('x^3+4*x^2-10'); % plot it fplot(f,[-4,3]); xlabel('x'),ylabel('f(x)=x^3+4*x^2-10'); % The bisection algorithm a=1.0; b=2.0; FA=f(a); FP=f(a); iter=0; while FP~=0 & (b-a)>=10^(-4) p=a+(b-a)/2; FP=f(p); iter=iter+1; if FA*FP>0 a=p; FA=FP; else b=p; end end