function J = p21_j ( m, n, x )

%*****************************************************************************80
%
%% p21_j() evaluates the jacobian for problem 21.
%
%  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 = [ 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 ];

  hfac = 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
