function f = p22_f ( m, n, x )

%*****************************************************************************80
%
%% p22_f() evaluates the M nonlinear functions for problem 22.
%
%  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.14272; -0.184918; -0.521869; -0.685306 ];

  B = [ ...
     2.95137,  4.87407, -2.0506; ...
     4.87407,  9.39321, -3.93189; ...
    -2.0506,  -3.93189,  2.64745 ];

  C = [ ...
    -0.564255,  0.392417,  -0.404979; ...
     0.927589, -0.0735083,  0.535493; ...
     0.658799, -0.636666,  -0.681091; ...
    -0.869487,  0.586387,   0.289826 ];

  d = [ 1.75168; -1.35195; -0.479048; -0.3648 ];

  xbx = x' * ( B * x );

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

  return
end
