function fjac = p07_jac ( n, x )

%*****************************************************************************80
%
%% P07_JAC sets the jacobian for problem 7.
%
%  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 );

  for j = 1 : n

    t1 = 1.0;
    t2 = x(j);

    t4 = 0.0;
    t5 = 1.0;

    for i = 1 : n

      fjac(i,j) = t5;

      t6 = 2.0 * t2 + 2.0 * t5 * x(j) - t4;
      t4 = t5;
      t5 = t6;

      t3 = 2.0 * x(j) * t2 - t1;
      t1 = t2;
      t2 = t3;

    end

  end

  fjac(1:n,1:n) = fjac(1:n,1:n) / n;

  return
end

