Está en la página 1de 3

MÉTODO DEL PUNTO FIJO

function METODOPUNTOFIJO
global funcion1 funcion
fprintf('METODO DE PUNTO FIJO:\n');
funcion=input('INGRESE LA FUNCIÓN y(x):\n','s');
funcion1=input('INGRESE LA FUNCIÓN g(x):\n','s');
x0=input('INGRESE EL PUNTO INICIAL:\n');
error=input('INGRESE EL ERROR :\n');
it=0;
fprintf('it x0 x1 x0-x1');
while(it<50)
it=it+1;
x=x0;
x1=eval(funcion1);
fprintf('\n%3.0f%13.9f%13.9f\n%13.9f\n',it,x0,x1,abs(x0-x1));
if(abs(x1-x0)<error)
fprintf('el proceso se cumple satisfactoriamente:\n');
break
end
x0=x1;
end

METODO DE PUNTO FIJO:

INGRESE LA FUNCIÓN y(x): cos(x)-3*x

INGRESE LA FUNCIÓN g(x): cos(x)/3

INGRESE EL PUNTO INICIAL: 0.3

INGRESE EL ERROR : 0.0001

it x0 x1 x0-x1

1 0.300000000 0.318445496 0.018445496

2 0.318445496 0.316574422 0.001871074

3 0.316574422 0.316769140 0.000194718

4 0.316769140 0.316748928 0.000020212

El proceso se cumple satisfactoriamente:


MÉTODO DE NEWTON RAPHSON
function METODORAPHSON
global funcion1 funcion
fprintf('METODO DE NEWTONRAPHSON:\n');
funcion=input('INGRESE LA FUNCIÓN y(x):\n','s');
funcion1=input('INGRESE LA FUNCIÓN DEL ALGORITMO x(i+1):\n','s');
x0=input('INGRESE EL PUNTO INICIAL:\n');
error=input('INGRESE EL ERROR :\n');
it=0;
fprintf('it x0 x1 x0-x1');
while(it<50)
it=it+1;
x=x0;
x1=eval(funcion1);
fprintf('\n%3.0f%13.9f%13.9f\n%13.9f\n',it,x0,x1,abs(x0-x1));
if(abs(x1-x0)<error)
fprintf('el proceso se cumple satisfactoriamente:\n');
break
end
x0=x1;
end

METODO DE NEWTONRAPHSON:

INGRESE LA FUNCIÓN y(x): x^2-sin(x+2)

INGRESE LA FUNCIÓN DEL ALGORITMO x(i+1): x0-((x0^2-sin(x0+2))/(2*x0-cos(x0+2)))

INGRESE EL PUNTO INICIAL: 0.7

INGRESE EL ERROR :

0.001

it x0 x1 x0-x1

1 0.700000000 0.672821980 0.027178020

2 0.672821980 0.672420016 0.000401963

El proceso se cumple satisfactoriamente:

También podría gustarte