function alpert_regular_test ( )

%*****************************************************************************80
%
%% ALPERT_REGULAR_TEST tests the Alpert rule on the regular integrand.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    23 November 2015
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ALPERT_REGULAR_TEST\n' );
  fprintf ( 1, '  Test the Alpert rule on the regular integrand.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Rule  Order   J   A        N     N+2J               H        Estimate           Error\n' );
  fprintf ( 1, '\n' );

  v2 = integral_regular ( );

  num_r = num_regular ( );

  for rule = 1 : num_r

    a = a_regular ( rule );
    j = j_regular ( rule );
    order = order_regular ( rule );
    [ x, w ] = rule_regular ( rule, j );

    n = 8;

    for nlog = 4 : 6

      n = n * 2;
      h = 1.0 / real ( n + 2 * a - 1 );

      x1 = h * x; 
      s1 = w(1:j)' * integrand_regular ( j, x1 );

      x2 = linspace ( a * h, ( a + n - 1 ) * h, n );
      s2 = sum ( integrand_regular ( n, x2 ) );

      x3 = 1.0 - h * x;
      s3 = w(1:j)' * integrand_regular ( j, x3 );

      v1 = h * ( s1 + s2 + s3 );

      fprintf ( 1, '    %2d     %2d  %2d  %2d  %7d  %7d  %14.6g  %14.6g  %14.6g\n', ...
        rule, order, j, a, n, n + 2 * j, h, v1, abs ( v1 - v2 ) );
    end

    fprintf ( 1, '\n' );

  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '                                                  Exact: %14.6g\n', v2 );

  return
end

