function rc_test2 ( )

%*****************************************************************************80
%
%% RC_TEST2 checks RC by examining special values.
%
%  Discussion:
%
%    This driver compares values of (LOG X)/(X-1) and ARCTAN(X)
%    calculated on one hand from the subroutine RC and on the other
%    from library LOG and ARCTAN routines.  to avoid over/underflows
%    for extreme values of X, we write (LOG X)/(X-1) = RC(Y,X/Y)/SQRT(Y),
%    where Y = (1+X)/2, and ARCTAN(X) = SQRT(X)*RC(Z,Z+X), where Z = 1/X.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    31 May 2018
%
%  Author:
%
%    Original FORTRAN77 version by Bille Carlson, Elaine Notis.
%    This MATLAB version by John Burkardt.
%
  x_vec = [ ...
   1.0E-75, ...
   1.0E-15, ...
   1.0E-03, ...
   1.0E-01, ...
   2.0E-01, ...
   5.0E-01, ...
   1.0E+00, ...
   2.0E+00, ...
   5.0E+00, ...
   1.0E+01, ...
   1.0E+03, ...
   1.0E+15, ...
   1.0E+75 ];

  fprintf ( 1, '\n' );
  fprintf ( 1, 'RC_TEST2\n' );
  fprintf ( 1, '  Compare LOG(X)/(X-1) and ARCTAN(X) with\n' );
  fprintf ( 1, '  values based on RC.\n' );

  fprintf ( 1, '\n' );
  fprintf ( 1, '     X               From LOG                   From RC\n' );
  fprintf ( 1, '\n' );

  errtol = 1.0E-3;

  for j = 1 : 10
    x = 0.2 * j;
    y = ( 1.0 + x ) / 2.0;
    v = x / y;
    [ value, ierr ] = rc ( y, v, errtol );
    mylog = value / sqrt ( y );
    if ( j == 5 )
      fprintf ( 1, '%9.1g     ***** ZERO DIVIDE *****%27.16g\n', x, mylog );
    else
      ibmlog = log ( x ) / ( x - 1.0 );
      fprintf ( 1, '%9.1g     %27.16g%27.16g\n', x, ibmlog, mylog );
    end
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Extreme values of X\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '     X               From LOG                   From RC\n' );
  fprintf ( 1, '\n' );

  for i = 1 : 16
    ipower = - 75 + 10 * ( i - 1 );
    x = 10.0 ^ ipower;
    y = ( 1.0 + x ) / 2.0;
    v = x / y;
    [ value, ierr ] = rc ( y, v, errtol );
    mylog = value / sqrt ( y );
    ibmlog = log ( x ) / ( x - 1.0 );
    fprintf ( 1, '%9.1g     %27.16g%27.16g\n', x, ibmlog, mylog );
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '     X              From ARCTAN                 From RC\n' );
  fprintf ( 1, '\n' );

  for m = 1 : 13
    x = x_vec(m);
    z = 1.0 / x;
    w = z + x;
    [ value, ierr ] = rc ( z, w, errtol );
    myarc = sqrt ( x ) * value;
    ibmarc = atan ( x );
    fprintf ( 1, '%9.1g     %27.16g%27.16g\n', x, ibmarc, myarc );
  end

  return
end
