function fjac = p04_jac ( n, x )

%*****************************************************************************80
%
%% P04_JAC sets the jacobian for problem 4.
%
%  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) = - 200.0 * ( x(2) - 3.0 * x(1)^2 ) + 1.0;
  fjac(1,2) = - 200.0 * x(1);
  fjac(1,3) = 0.0;
  fjac(1,4) = 0.0;

  fjac(2,1) = - 400.0 * x(1);
  fjac(2,2) =   220.2;
  fjac(2,3) =     0.0;
  fjac(2,4) =    19.8;

  fjac(3,1) = 0.0;
  fjac(3,2) = 0.0;
  fjac(3,3) = - 180.0 * ( x(4) - 3.0 * x(3)^2 ) + 1.0;
  fjac(3,4) = - 180.0 * x(3);

  fjac(4,1) =     0.0;
  fjac(4,2) =    19.8;
  fjac(4,3) = - 360.0 * x(3);
  fjac(4,4) =   300.2;

  return
end

