function [ t, x ] = map_interation ( f, n, x0 )

%*****************************************************************************80
%
%% map_iteration() applies an iterative map repeatedly.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 January 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    function handle f: a function of the form xnew=f(xold).
%
%    integer n: the number of times the iteration is to be applied.
%
%    real x0(2): the initial condition.
%
%  Output:
%
%    real t(n+1): the parameter values.
%
%    real x(n+2,2): the sequence of iterates.
%
  x0 = x0(:);
  d = length ( x0 );
  t = zeros ( n + 1 );
  x = zeros ( n + 1, d );

  for i = 0 : n

    if ( i == 0 )
      t(i+1) = 0.0;
      x(i+1,:) = x0(:);
    else
      t(i+1) = t(i) + 1.0;
      x(i+1,:) = f ( x(i,:) );
    end

  end

  return
end

