% La méthode du point fixe ; % On a l'équation f(x)=cos(x)-x =0 clear all; clc; x = 0.5:0.01:5; g=inline('sqrt(10-x.^3)/2'); %g = inline('exp(sin(x))'); % exercice %g=inline('2*sin(x)'); % exemple 2 plot(x,g(x),x,x); grid ; x0 = input('x0 = '); eps = input('eps = '); nmax = input('nmax = '); n=1; while (n<=nmax) x = x0; x0 = g(x); err = abs(x0-x); n=n+1; if err <= eps fprintf(' pour i=%d\t la solution x0=%f\t avec erreur = %f \n',n,x0,err); end end