function quad_serial_test ( )

%*****************************************************************************80
%
%% quad_serial_test() tests quad_serial().
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    18 October 2024
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../quad_serial' )

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'quad_serial_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test quad-serial().\n' );

  a =  0.0;
  b = 10.0;
  n = 10000000;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Estimate the integral of f(x) from A to B.\n' );
  fprintf ( 1, '  f(x) = 50 / ( pi * ( 2500 * x * x + 1 ) ).\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  A        = %f\n', a );
  fprintf ( 1, '  B        = %f\n', b );
  fprintf ( 1, '  N        = %d\n', n );

  tic ( );
  q = quad_serial ( @f, a, b, n );
  t = toc ( );

  exact = 0.49936338107645674464;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Exact    = %24.16f\n', exact );
  fprintf ( 1, '  Estimate = %24.16f\n', q );
  fprintf ( 1, '  Error    = %e\n', abs ( q - exact ) );
  fprintf ( 1, '  Time     = %f\n', t );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'quad_serial_test():\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../quad_serial' )

  return
end
function value = f ( x )

%*****************************************************************************80
%
%% f() evaluates the integrand function.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  value = 50.0 / ( pi * ( 2500.0 * x * x + 1.0 ) );

  return
end
function timestamp ( )

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

  return
end

