function fx = p12_fx ( n, x )

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

  sum1 = 0.0;
  for j = 1 : n
    sum1 = sum1 + j * ( x(j) - 1.0 );
  end

  for k = 1 : n
    fx(k) = x(k) - 1.0 + k * sum1 * ( 1.0 + 2.0 * sum1 * sum1 );
  end

  return
end

