function quad2d_test ( )

%*****************************************************************************80
%
%% quad2d_test() tests quad2d().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    08 December 2020
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../quad2d' );

  timestamp ( )
  fprintf ( 1, '\n' );
  fprintf ( 1, 'quad2d_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test quad2d().\n' );

  a = 0.0;
  b = 1.0;
  c = 0.0;
  d = 1.0;
  nx = 16384;
  ny = 16384;
  n = nx * ny;

  fprintf ( 1, '  Estimate the integral of f(x,y) over [a,b]x[c,d].\n' );
  fprintf ( 1, '  f(x,y) = 1 / ( 1 - x * y ).\n' );
  fprintf ( 1, '  using a %d x %d grid of %d points.\n', nx, ny, n );
  fprintf ( 1, '  %g <= x <= %g\n', a, b );
  fprintf ( 1, '  %g <= y <= %g\n', c, d );

  tic;

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

  wtime = toc;

  exact = pi * pi / 6.0;
  error = abs ( exact - estimate );
 
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Exact =    %g\n', exact );
  fprintf ( 1, '  Estimate = %g\n', estimate );
  fprintf ( 1, '  Error    = %g\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 ( );

  rmpath ( '../quad2d' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

