function f = p15_f ( m, n, x )

%*****************************************************************************80
%
%% p15_f() evaluates the M nonlinear functions for problem 15.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 March 2026
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Jorge More, Burton Garbow, and Kenneth Hillstrom,
%    Testing unconstrained optimization software,
%    ACM Transactions on Mathematical Software,
%    Volume 7, pages 17-41, 1981.
%
%  Input:
%
%    integer M, the number of functions.
%
%    integer N, the number of unknowns.
%
%    real X(N), the evaluation point.
%
%  Output:
%
%    real F(M), the value of the functions evaluated at X.
%
  f = zeros ( m, 1 );

  for j = 1 : n
    tmp1 = 1.0;
    tmp2 = 2.0 * x(j) - 1.0;
    temp = 2.0 * tmp2;
    for i = 1 : m
      f(i) = f(i) + tmp2;
      ti = temp * tmp2 - tmp1;
      tmp1 = tmp2;
      tmp2 = ti;
    end
  end

  dx = 1.0 / n;

  iev = -1;
  for i = 1 : m
    f(i) = dx * f(i);
    if ( 0 < iev )
      f(i) = f(i) + 1.0 / ( i * i - 1.0 );
    end
    iev = - iev;
  end

  return
end
