function fx = p13_fx ( n, x )

%*****************************************************************************80
%
%% P13_FX evaluates the function for problem 13.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 October 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of variables and equations.
%
%    real X(N), the evaluation point.
%
%  Output:
%
%    real FX(N), the function value.
%
  fx = zeros ( n, 1 );

  for k = 1 : n

    fx(k) = ( 3.0 - 2.0 * x(k) ) * x(k) + 1.0;

    if ( 1 < k )
      fx(k) = fx(k) - x(k-1);
    end

    if ( k < n )
      fx(k) = fx(k) - 2.0 * x(k+1);
    end

  end

  return
end

