function quad_monte_carlo_test ( )

%*****************************************************************************80
%
%% quad_monte_carlo_test() tests quad_monte_carlo().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    24 July 2019
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../quad_monte_carlo' );

  timestamp ( );
  fprintf ( 1, 'quad_monte_carlo_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  quad_monte_carlo() is an interactive program which uses\n' );
  fprintf ( 1, '  n random samples to estimate the integral of a\n' );
  fprintf ( 1, '  function f(x) over the interval [a,b].\n' );
%
%  Use variables as the arguments.
%
  f = 'x.^2';
  a = 0.0;
  b = 1.0;
  n = 100;
  label = sprintf ( '  Estimate integral ( %f < x < %f ) %s dx', a, b, f );
  fprintf ( 1, '\n' );
  fprintf ( 1, '%s\n', label );
  q = quad_monte_carlo ( f, a, b, n );
%
%  Use literals as the arguments.
%
  label = '  Estimate integral ( 0.0 < x < 2.0 ) sqrt(x) dx';
  fprintf ( 1, '\n' );
  fprintf ( 1, '%s\n', label );
  q = quad_monte_carlo ( 'sqrt(x)', 0.0, 2.0, 1000 );
%
%  Use a user M-file as the function argument.
%
  label = '  Estimate integral ( 0.0 < x < 2.0 ) humps(x) dx';
  fprintf ( 1, '\n' );
  fprintf ( 1, '%s\n', label );
  n = 1;
  for i = 0 : 20
    q = quad_monte_carlo ( 'humps_fun(x)', 0.0, 2.0, n );
    n = n * 2;
  end
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'quad_monte_carlo_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  timestamp ( );

  rmpath ( '../quad_monte_carlo' );

  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

