Sei sulla pagina 1di 1

METODO DEL PUNTO FIJO

%metodo del punto fijo


xf(1)=input('Ingrese el primer valor : ');
tol=input('Ingrese el porcentaje de error: ');
syms x;
f=input('Ingrese la funcin f(x), despejada g(f(x)): ');
i=1;
ea(1)=100;
whileabs(ea(i))>=tol,
xf(i+1) = subs(f,x,xf(i));
ea(i+1) = abs((xf(i+1)-xf(i))/xf(i+1))*100;
i=i+1;
end
fprintf('i xf(i) Error aprox (i) \n');
for j=1:i;
fprintf('%2d \t %11.7f \t %7.3f \n',j-1,xf(j),ea(j));
end

SALIDA
>>puntofijo
Ingrese el primer valor : 0.52
Ingrese el porcentaje de error: 1
Ingrese la funcin f(x), despejada g(f(x)): sin(x)+x+1
i xf(i) Error aprox (i)
0 0.5200000 100.000
1 2.0168801 74.218
2 3.9190237 48.536
3 4.2175729 7.079
4 4.3375168 2.765
5 4.4069624 1.576
6 4.4532436 1.039
7 4.4866343 0.744

Potrebbero piacerti anche