function [c,it, a, b] = my_bisect_05_05(f,a,b,tol, itmax) %bisection method %stop condition: |f(c_k)|<=tol o it>itmax it=0; ya=f(a);yb=f(b); if (ya*yb>0) disp('intervallo non adatto'); return; end err=inf; while (err>tol & it<=itmax) c=(a+b)/2; yc=f(c); if (ya*yc<=0) b=c; yb=yc; else a=c; ya=yc; end err=abs(yc); it=it+1; end end