% Program 1.2 Fixed-Point Iteration
%
% Modified to return all iterates
%
% Computes an approximate solution of g(x) = x
%
% Input: inline function g, 
%        starting guess x0, 
%        number of steps k
%
% Output: Vector x of all iterates of the FPI process.  Presumably, the
%         best approximation is the last value of the vector.
%
function x = fpi2(g, x0, k)
   x(1) = x0;
   for i = 1:k
      x(i + 1) = g(x(i));
   end
end

