function quad2d_test ( )

%*****************************************************************************80
%
%% quad2d_test does a serial quadrature estimate.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    25 October 2011
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
  a = 0.0;
  b = 1.0;
  nx = 32768;
  ny = 32768;
  n = nx * ny;
  exact = pi * pi / 6.0;

  timestamp ( )
  fprintf ( 1, '\n' );
  fprintf ( 1, 'quad2d_test:\n' );
  fprintf ( 1, '  MATLAB version\n' );
  fprintf ( 1, '  Estimate the integral of f(x,y) over [0,1]x[0,1].\n' );
  fprintf ( 1, '  f(x,y) = 1 / ( 1 - x * y ).\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  A        = %f\n', a );
  fprintf ( 1, '  B        = %f\n', b );
  fprintf ( 1, '  NX       = %d\n', nx );
  fprintf ( 1, '  NY       = %d\n', ny );
  fprintf ( 1, '  N        = %d\n', n );
  fprintf ( 1, '  Exact    = %f\n', exact );

  tic;

  total = 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 ) * a + ( 2 * j - 1 ) * b ) / ( 2 * ny );
      total = total + f ( x, y );
    end
  end

  wtime = toc;

  total = ( b - a ) * ( b - a ) * total / nx / ny;
  error = abs ( total - exact );
 
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Estimate = %f\n', total );
  fprintf ( 1, '  Error    = %f\n', error );
  fprintf ( 1, '  Time     = %f\n', wtime );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'quad2d_test:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  return
end
