function hump_gauss ( tol )

%*****************************************************************************80
%
%% hump_gauss estimates the integral of hump(x), with estimated error < tol.
%
%  Discussion:
%
%    The error is estimated by comparing two successive Gauss quadrature
%    values.
%
%  Input:
%
%    real tol: the error tolerance.
%
  a = 0.0;
  b = 2.0;

  nmax = 100;

  q_exact = hump_int ( a, b );

  n = 0;
  q = 0.0;

  fprintf ( 1, '\n' );
  fprintf ( 1, '  n    integral         error          error\n' );
  fprintf ( 1, '       estimate         estimate       exact\n' );
  fprintf ( 1, '\n' );

  while ( )

    q_prev = q;
    n = n + 1;

    if ( nmax < n )
      fprintf ( 1, 'hump_gauss: Failure!\n' );
      fprintf ( 1, '  The value of n = %d exceeded our limit.\n', n );
      return
    end

    [ x, w ] = gauss_ab ( n, a, b );
    q = w' * hump ( x );
    err_est = q - q_prev;
    err_exact = q - q_exact;
    fprintf ( 1, '  %2d  %16.12f  %e  %e\n', n, q, err_est, err_exact );

    if ( abs ( err_est ) < tol )
      break;
    end

  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Integral estimate is %g\n', q );
  fprintf ( 1, '  Our error is estimated to be less than the tolerance %g\n', tol );

  return
end

