function fjac = p00_dif ( problem, n, x )

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

  eps = 0.0001;

  for j = 1 : n

    if ( 0.0 <= x(j) )
      dxj = eps * ( x(j) + 1.0 );
    else
      dxj = eps * ( x(j) - 1.0 );
    end

    xsave = x(j);

    x(j) = xsave - dxj;
    fminus = p00_fx ( problem, n, x );

    x(j) = xsave + dxj;
    fplus = p00_fx ( problem, n, x );

    fjac(1:n,j) = ( fplus(1:n) - fminus(1:n) ) / 2.0 / dxj;

    x(j) = xsave;

  end

  return
end

