function quad_2d ( m, n )

%*****************************************************************************80
%
%% QUAD_2D applies a 2D product quadrature rule to an integral.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    24 February 2013
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer M, N, the orders of the rules for X and Y.
%

%
%  Compute the Legendre rule for X and Y, adjusting from [-1,+1] to [0,1].
%
  [ x, u ] = legendre_ek_compute ( m );
  [ x, u ] = rule_adjust ( -1, +1, 0, 1, m, x, u );

  [ y, v ] = legendre_ek_compute ( n );
  [ y, v ] = rule_adjust ( -1, +1, 0, 1, n, y, v );
%
%  The function F(X,Y) = exp ( - (x-xbar)^2 - (y-ybar)^2 )
%  so set XBAR and YBAR here.
%
  xbar = 0.3;
  ybar = 0.4;
%
%  Here is the exact integral.
%
  t = pi * ( erf ( 1 - xbar ) + erf ( xbar ) ) ...
         * ( erf ( 1 - ybar ) + erf ( ybar ) ) / 4;
%
%  The 2D quadrature rule is the produce of the 1D quadrature rules.
%
  q = 0.0;
  for j = 1 : n
    for i = 1 : m
      arg = ( x(i) - xbar )^2 + ( y(j) - ybar )^2;
      fxy = exp ( - arg );
      q = q + u(i) * v(j) * fxy;
    end
  end
%
%  Compute and print the error.
%
  e = abs ( t - q );
  fprintf ( 1, '  %2d  %2d  %14.6g\n', m, n, e );

  return
end


