function fx = p07_fx ( n, x )

%*****************************************************************************80
%
%% p07_fx() evaluates the function for problem 7.
%
%  Discussion:
%
%    The Chebyquad function is related to the computation of the
%    abscissas for Chebyshev quadrature.
%
%  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 j = 1 : n

    t1 = 1.0;
    t2 = x(j);

    for i = 1 : n

      fx(i) = fx(i) + t2;

      t3 = 2.0 * x(j) * t2 - t1;
      t1 = t2;
      t2 = t3;

    end

  end

  fx(1:n) = fx(1:n) / n;

  for i = 1 : n

    if ( mod ( i, 2 ) == 0 )
      fx(i) = fx(i) + 1.0 / ( i * i - 1 );
    end

  end

  return
end

