function r8_agm_test ( )

%*****************************************************************************80
%
%% r8_agm_test() tests r8_agm().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 May 2015
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'R8_AGM_TEST:\n' );
  fprintf ( 1, '  R8_AGM computes the arithmetic geometric mean.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '             X              Y              AGM           AGM\n' );
  fprintf ( 1, '                                           Exact         Computed\n' );
  fprintf ( 1, '\n' );

  n_data = 0;

  while ( true )

    [ n_data, x, y, fx1 ] = agm_values ( n_data );

    if ( n_data == 0 )
      break
    end

    fx2 = r8_agm ( x, y );

    fprintf ( 1, '  %14.6f  %14.6f  %24.16g  %24.16g\n', x, y, fx1, fx2 );

  end

  return
end
