
%-------------------------------
% El método de punto fijo intenta
% resolver de forma iterativa la 
% solución de la ecuacion 
% f(x)  =  x - g(x)  =  0
%-------------------------------

function [x,iter,Res]  =  MyFixedPointIteration(g,tol,x0,NMaxIter)


Res             =  zeros(NMaxIter,1);
iter            =  0;
x               =  x0;
while and(norm(x-g(x))>tol,iter<NMaxIter)
  iter          =  iter + 1;
  Res(iter)     =  norm(x - g(x));
  x             =  g(x);  
end
Res(iter+1)     =  norm(x - g(x));
if iter+1<NMaxIter
     Res(iter+2:end) =  [];
end
iter  =  iter + 1;