function g = p00_g ( nprob, m, n, x )

%*****************************************************************************80
%
%% p00_g() estimates the least squares gradient for any problem.
%
%  Discussion:
%
%    If we write the least squares function as
%
%      FSQ = Sum ( 1 <= I <= M ) F(X)**2
%
%    then the least squares gradient vector is:
%
%      G(J) = d FSQ / d X(J) =
%        Sum ( 1 <= I <= M ) 2 * F(X) * d F(X)/d X(J)
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    03 March 2026
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer NPROB, the problem number.
%
%    integer M, the number of equations.
%
%    integer N, the number of variables.
%
%    real X(N), the evaluation point.
%
%  Output:
%
%    real G(N), the least squares gradient vector.
%
  f = p00_f ( nprob, m, n, x );
  J = p00_j ( nprob, m, n, x );

  g = 2.0 * ( J * f )';

  return
end
