Está en la página 1de 1

function [k,p, errorabsoluto,P ] = puntofijo(g,p0,tolerancia, iteracionesmaximas ) P(1)=p0; fplot(g,[-2,2]) for k=2: iteracionesmaximas P(k)=feval(g,P(k-1)); errorabsoluto=abs(P(k)-P(k-1)); errorrelativo = errorabsoluto/(abs(P(k))+eps); p=P(k);

if (errorabsoluto < tolerancia) | (errorrelativo < tolerancia), break; end end if k== iteracionesmaximas disp('superado el numero maximo de iteraciones') end P=P'; end function g = g2(x); g=x^2-sin(x+0.15); end

También podría gustarte