function J = p22_j ( m, n, x )

%*****************************************************************************80
%
%% p22_j() evaluates the jacobian for problem 22.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%  Modified:
%
%    03 March 2026
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the number of equations.
%
%    integer N, the number of variables.
%
%    real X(N), the evaluation point.
%
%  Output:
%
%    real J(M,N), the jacobian matrix.
%
  J = zeros ( m, n );

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

  C = reshape ( (/ &
    -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 ];

  h = zeros ( n, 1 );
  for j = 1 : n
    hfac(j) = 0.0;
    for k = 1 : n
      hfac(j) = hfac(j) + 0.5 * ( B(j,k) + B(k,j) ) * x(k);
    end
  end

  for j = 1 : n
    J(1:m,j) = C(1:m,j) + d(1:m) * hfac(j);
  end

  return
end
