function f = p21_f ( m, n, x )

%*****************************************************************************80
%
%% p21_f() evaluates the M nonlinear functions for problem 21.
%
%  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 );

  a = [ 0.13294; -0.244378; 0.325895 ];

  B = [ 5.66598, 2.77141; ...
        2.77141, 2.12413 ];

  C = [ ...
    -0.564255,  0.392417; ...
    -0.404979,  0.927589; ...
    -0.0735084, 0.535493 ];

  d = [ 2.5074; -1.36401; 1.02282 ];

  xbx = x' * ( B * x );

  f(1:m) = a(1:m) + C * x + 0.5 * d(1:m) * xbx;

  return
end
