function hypersphere_monte_carlo_test01 ( )

%*****************************************************************************80
%
%% hypersphere_monte_carlo_test01() tests hypersphere01_sample().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 January 2014
%
%  Author:
%
%    John Burkardt
%
  m = 3;

  e_test(1:m,1:7) = [ ...
    0, 0, 0; ...
    2, 0, 0; ...
    0, 2, 0; ...
    0, 0, 2; ...
    4, 0, 0; ...
    2, 2, 0; ...
    0, 0, 4 ]';

  fprintf ( 1, '\n' );
  fprintf ( 1, 'hypersphere_monte_carlo_test01\n' );
  fprintf ( 1, '  hypersphere01_sample() estimates integrals over \n' );
  fprintf ( 1, '  the surface of the unit hypersphere in M dimensions.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Spatial dimension M = %d\n', m );

  fprintf ( 1, '\n' );
  fprintf ( 1, '         N        1              X^2             Y^2' )
  fprintf ( 1, '             Z^2             X^4           X^2Y^2           Z^4\n' );
  fprintf ( 1, '\n' );

  n = 1;

  while ( n <= 65536 )

    x = hypersphere01_sample ( m, n );

    fprintf ( 1, '  %8d', n );

    for j = 1 : 7

      e(1:m,1) = e_test(1:m,j);

      value(1:n,1) = monomial_value ( m, n, e, x );

      result = hypersphere01_area ( m ) * sum ( value(1:n) ) / n;

    fprintf ( 1, '  %14f', result );

    end

    fprintf ( 1, '\n' );

    n = 2 * n;

  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '     Exact' );
  for j = 1 : 7

    e(1:m,1) = e_test(1:m,j);

    result = hypersphere01_monomial_integral ( m, e );

    fprintf ( 1, '  %14f', result );

  end
  fprintf ( 1, '\n' );

  return
end
