//Activité 2 : xn+1 = xn-[f(xn)(xn-xn-1)]/[f(xn)-f(xn-1)] ordre 1 (géométrique) function y=f(x) y=x.*x-2 endfunction function [x,n]=regulafalsi(f,a,b,e) if f(a)*f(b)>0 then disp("Condition d existence non vérifiée"); return; end x0=a x=b n=0 while (abs(x-x0)>e | f(x)>10^(-15)) & n< 50 n=n+1 x0=x x=a-f(a)*(b-a)/(f(b)-f(a)) if (f(a)*f(x)<0) then a=a b=x else a=x b=b end end endfunction function graphe1(f,a,b) x=linspace(a,b,50) y=feval(x,f) plot2d(x,y) plot2d(x,0*x,1) n=0 i=1 while n==0 i=i+1 plot2d([a b],[f(a) f(b)],i) c=a-(f(a)*(b-a))/(f(b)-f(a)) plot2d([c c],[0 f(c)],i) if ((f(a)*f(c))<0) then a=a b=c else a=c b=b end n=input("Pour continuer tapez 0 sinon 1") end endfunction