function agm_pi_test ( )

%*****************************************************************************80
%
%% agm_pi_test() tests agm_pi().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    20 December 2019
%
%  Author:
%
%    John Burkardt
%
  clear ( 'all' );

  fprintf ( 1, '\n' );
  fprintf ( 1, 'agm_pi_test()\n' );
  fprintf ( 1, '  agm_pi() computes the value of pi using the \n' );
  fprintf ( 1, '  arithmetic-geometric-mean approach.\n' );
%
%  Get pi to 10, 20, 40, 80 decimal digits:
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Request PI to 10, 20, 40, 80 digits.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Digits   PI:\n' );
  fprintf ( 1, '\n' );

  d = 10;

  for i = 1 : 4

    p = agm_pi ( d )

    d = d * 2;

  end
%
%  Timings.
%  Apparently, D = 1 is illegal input to AGM_PI!
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  How long does it take to compute PI to D digits?\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '          Digits    Seconds\n' );
  fprintf ( 1, '\n' );
  d = 2;
  for i = 1 : 20
    tic
    p = agm_pi ( d );
    t = toc;
    fprintf ( 1, '  %2d  %10d  %14g\n', i, d, t ); 
    d = d * 2;
  end
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'agm_pi_test()\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end



