Sei sulla pagina 1di 1

% Metodo: Del punto fijo

Clear, clc

Cf =input(’ingrese función f: ´);

Cg =input(’ingrese función g: ´);

f= inline (cg) ;

g= inline (cg) ;

syms x

dg = diff(cg, x);

x= input( ’ingresar el primer valor : ’);

if( abs( eval (dg)<1 )

tol = input( ’ ingrese tolerancia: ’) ;

disp( ’ n x0 error ’)

fprintf (’ 0.0000 %7.4f ---------\n’ , x)

n= 0; error =100;

while( error > tol )

n= n+1;

x = g(x) ;

error = abs (f(x)) ;

disp. ([n,x,error])

end

else

disp(’ ingrese otra function g(x) ; pues con la actual, el metodo diverge. ’)

end

Potrebbero piacerti anche