function fx = p09_fx ( n, x )

%*****************************************************************************80
%
%% P09_FX evaluates the function for problem 9.
%
%  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 );

  h = 1.0 / ( n + 1 );

  for k = 1 : n

    fx(k) = 2.0 * x(k) + 0.5 * h * h * ( x(k) + k * h + 1.0 )^3;

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

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

  end

  return
end

