function r8_lgmc_test ( )

%*****************************************************************************80
%
%% R8_LGMC_TEST tests R8_LGMC.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    25 April 2016
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../test_values' );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'R8_LGMC_TEST:\n' );
  fprintf ( 1, '  R8_LGMC evaluates the correction log gamma factor.\n' );
  fprintf ( 1, '  r8_lgmc(x) = log ( gamma ( x ) ) - log ( sqrt ( 2 * pi )\n' );
  fprintf ( 1, '    - ( x - 0.5 ) * log ( x ) + x\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '             X        LGMC(X)  R8_LGMC(X)        Diff\n' );
  fprintf ( 1, '\n' );

  n_data = 0;

  while ( 1 )

    [ n_data, x, gamma_log ] = gamma_log_values ( n_data );

    if ( n_data == 0 )
      break
    end
%
%  Function requires 10 <= x.
%
    if ( 10.0 <= x )
      fx1 = gamma_log - log ( sqrt ( 2.0 * pi ) ) - ( x - 0.5 ) * log ( x ) + x;
      fx2 = r8_lgmc ( x );
      fprintf ( 1, '  %14.4f  %14.6g  %14.6g  %14.6g\n', x, fx1, fx2, abs ( fx1 - fx2 ) );
    end

  end

  rmpath ( '../test_values' );

  return
end
