function midpoint_test ( )

%*****************************************************************************80
%
%% midpoint_test() applies a composite midpoint rule to finite interval 1D problems.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    02 September 2022
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'midpoint_test():\n' );
  fprintf ( 1, '  Composite midpoint rule,\n' );
  fprintf ( 1, '  for 1D finite interval problems.\n' );

  prob_num = p00_prob_num ( );

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Intervals   Approx       Error\n' );
%
%  Pick a problem.
%
  for prob = 1 : prob_num

    exact = p00_exact ( prob );

    fprintf ( 1, '\n' );
    fprintf ( 1, '  Problem %d:\n', prob );
%
%  Pick a number of subintervals.
%
    for int_log = 0 : 20

      int_num = 2^int_log;

      result = p00_midpoint ( prob, int_num );

      error = abs ( exact - result );

      fprintf ( 1, '  %7d  %14.10f  %14e\n', int_num, result, error );

    end

    fprintf ( 1, '    Exact  %14.10f\n', exact );

  end

  return
end
