% Function [zero,erreur,niter] = pointfixe(g,x0,tol,nmax) % La méthode du point fixe ; % On a l'équation f(x)=cos(x)-x =0 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 = '); for n = 1 : nmax x = x0; x0 = g(x); err = abs(x0-x); if err <= eps fprintf(' pour i=%d\t la solution x0=%f\t avec erreur = %f \n',n,x0,err); end end