function disk01_quarter_monte_carlo_test01 ( )

%*****************************************************************************80
%
%% DISK01_QUARTER_MONTE_CARLO_TEST01 demonstates the Monte Carlo method.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    05 May 2016
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'DISK01_QUARTER_MONTE_CARLO_TEST01\n' );
  fprintf ( 1, '  Use DISK01_QUARTER_SAMPLE to estimate integrals\n' );
  fprintf ( 1, '  in the unit quarter disk.\n' );

  for i = 0 : 4
    e(1) = i; 
    for j = 0 : 4 - e(1)
      e(2) = j;
      exact = disk01_quarter_monomial_integral ( e );
      fprintf ( 1, '\n' );
      fprintf ( 1, '  Estimate integral of X^%d Y^%d\n', e(1), e(2) );
      fprintf ( 1, '\n' );
      fprintf ( 1, '         N        Estimate       Error\n' );
      fprintf ( 1, '\n' );

      n = 1;
      seed = 123456789;

      while ( n <= 65536 )

        [ x, seed ] = disk01_quarter_sample ( n, seed );
        value = monomial_value ( 2, n, e, x );

        q = disk01_quarter_area ( ) * sum ( value(1:n) ) / n;

        err = abs ( q - exact );
        fprintf ( 1, '  %8d  %14.6g  %10.2e\n', n, q, err );
        n = 2 * n;

      end
      fprintf ( 1, '    Exact:  %14.6g  %10.2g\n', exact, 0.0 );
    end

  end

  return
end
