function fjac = p02_jac ( n, x )

%*****************************************************************************80
%
%% P02_JAC sets the jacobian for problem 2.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 October 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of variables and equations.
%
%    real X(N), the evaluation point.
%
%  Output:
%
%    real FJAC(N,N), the jacobian matrix.
%
  fjac = zeros ( n, n );

  fjac(1,1) = 1.0;
  fjac(1,2) = 10.0;
  fjac(1,3) = 0.0;
  fjac(1,4) = 0.0;

  fjac(2,1) = 0.0;
  fjac(2,2) = 0.0;
  fjac(2,3) = sqrt ( 5.0 );
  fjac(2,4) = - sqrt ( 5.0 );

  fjac(3,1) = 0.0;
  fjac(3,2) = 2.0 * ( x(2) - 2.0 * x(3) );
  fjac(3,3) = - 4.0 * ( x(2) - 2.0 * x(3) );
  fjac(3,4) = 0.0;

  fjac(4,1) = 2.0 * sqrt ( 10.0 ) * ( x(1) - x(4) );
  fjac(4,2) = 0.0;
  fjac(4,3) = 0.0;
  fjac(4,4) = - 2.0 * sqrt ( 10.0 ) * ( x(1) - x(4) );

  return
end

