function [x,inum]=dichotomie(f,a,b,epsilon) // // Recherche d un zero d une fonction f entre a et b // avec la precision epsilon. // Methode dichotomie selon la formule d appel // [x,inum]=dichotomie(f,a,b,epsilon) // c = (a+b)/2; imax = 500; x = [c]; fb = f(b); fc = f(c); inum = 0; while (abs(fc) > epsilon) & (inum <= imax) if (fb*fc < 0) a=c; else b=c; fb = f(b); end c = (a+b)/2; fc = f(c); x = [x, c]; inum = inum+1; end endfunction