function estimate = quad2d ( nx, ny, a, b, c, d, f )

%*****************************************************************************80
%
%% quad2d() estimates the integral of a function over the rectangle [a,b]x[c,d].
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 August 2005
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
  estimate = 0.0;

  for i = 1 : nx
    x = ( ( 2 * nx - 2 * i + 1 ) * a + ( 2 * i - 1 ) * b ) / ( 2 * nx );
    for j = 1 : ny
      y = ( ( 2 * ny - 2 * j + 1 ) * c + ( 2 * j - 1 ) * d ) / ( 2 * ny );
      estimate = estimate + f ( x, y );
    end
  end
  estimate = ( b - a ) * ( d - c ) * estimate / nx / ny;

  return
end

