function elliptic_inc_pia_test ( )

%*****************************************************************************80
%
%% ELLIPTIC_INC_PIA_TEST tests ELLIPTIC_INC_PIA.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    22 June 2018
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ELLIPTIC_INC_PIA_TEST:\n' );
  fprintf ( 1, '  ELLIPTIC_INC_PIA returns values of\n' );
  fprintf ( 1, '  the incomplete elliptic integral of the\n' );
  fprintf ( 1, '  third kind, with parameters PHI, N, A.\n' );
  fprintf ( 1, '  Compare with MATLAB ellipticPi(n,phi,sin^2(a*pi/180))\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '          Phi             N               A                ')
  fprintf ( 1, 'ellipticPi(n,phi,*)    elliptic_inc_pia(phi,n,a)\n' );
  fprintf ( 1, '\n' );

  seed = 123456789;

  for i = 1 : 20

    [ phi, seed ] = r8_uniform_ab ( 0.0, 0.5 * pi, seed );
    nbound = ( 1.0 / sin ( phi ) ) ^ 2;
    [ n, seed ] = r8_uniform_ab ( - nbound, + nbound, seed );
    abound = ( 180.0 / pi ) * abs ( asin ( 1.0 / sin ( phi ) ) );
    [ a, seed ] = r8_uniform_ab ( - abound, + abound, seed );
    k = sin ( a * pi / 180.0 );
    fx1 = ellipticPi ( n, phi, k^2 );
    fx2 = elliptic_inc_pia ( phi, n, a );

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

  end

  return
end
