function alpert_log_test ( )

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

  v2 = integral_log ( );

  num_l = num_log ( );
%
%  For the righthand interval, use the regular rule of the same index.
%
  for rule = 1 : num_l

    a_l = a_log ( rule );
    j_l = j_log ( rule );
    order_l = order_log ( rule );
    [ x_l, w_l ] = rule_log ( rule, j_l );

    a_r = a_regular ( rule );
    j_r = j_regular ( rule );
    order_r = order_regular ( rule );
    [ x_r, w_r ] = rule_regular ( rule, j_r );

    n = 8;

    for nlog = 4 : 7

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

      x1 = h * x_l;
      f1 = integrand_log ( j_l, x1 );
      s1 = w_l(1:j_l)' * f1;

      x2 = linspace ( a_l * h, ( a_l + n - 1 ) * h, n );
      f2 = integrand_log ( n, x2 );
      s2 = sum ( f2 );

      x3 = 1.0 - h * x_r;
      f3 = integrand_log ( j_r, x3 );
      s3 = w_r(1:j_r)' * f3;

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

      fprintf ( 1, '    %2d     %4.1f  %2d  %2d  %7d  %7d  %14.6g  %14.6g  %14.6g\n', ...
        rule, order_l, j_l, a_l, n, n + j_l + j_r, h, v1, abs ( v1 - v2 ) );
    end

    fprintf ( 1, '\n' );

  end


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

  return
end

