function erfc_estimate_test ( )

%*****************************************************************************80
%
%% erfc_estimate_test() tests erfc_estimate(). 
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 May 2022
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'erfc_estimate_test():\n' );
  fprintf ( 1, '  erfc_estimate() uses an asymptotic expansion\n' );
  fprintf ( 1, '  to estimate erfc(x).\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '       X                Erfc(X)                   Erfc(x)                  Ratio\n' );
  fprintf ( 1, '                        estimated               tabulated\n' );

  for m = [ 1, 2, 3 ]

    fprintf ( 1, '\n' );
    fprintf ( 1, '  Using M = %d\n', m );
    fprintf ( 1, '\n' );

    n_data = 0;

    while ( true )

      [ n_data, x, erfc2 ] = erfc_values ( n_data );

      if ( n_data == 0 )
        break
      end

      erfc1 = erfc_estimate ( x, m );

      r = erfc1 / erfc2;

      fprintf ( 1, '  %8.4f  %20.8f  %20.8f  %8.4f\n', x, erfc1, erfc2, r );

    end

  end

  return
end
