function quad_trapezoid_test ( )

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

  timestamp ( );
  fprintf ( 1, 'quad_trapezoid_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  quad_trapezoid() applies\n' );
  fprintf ( 1, '  an n-interval trapezoid rule 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 = 10;
  label = sprintf ( '  Estimate integral ( %f < x < %f ) %s dx', a, b, f );
  fprintf ( 1, '\n' );
  fprintf ( 1, '%s\n', label );
  q = quad_trapezoid ( 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_trapezoid ( 'sqrt(x)', 0.0, 2.0, 10 );
%
%  Use a user M-file for the function.
%
  label = '  Estimate integral ( 0.0 < x < 2.0 ) humps(x) dx';
  fprintf ( 1, '\n' );
  fprintf ( 1, '%s\n', label );
  n = 1;
  for i = 1 : 9
    q = quad_trapezoid ( 'humps_fun(x)', 0.0, 2.0, n );
    n = n * 2;
  end
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'quad_trapezoid_test:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  timestamp ( );

  rmpath ( '../quad_trapezoid' );

  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

