function prism_witherden_rule_test02 ( p )

%*****************************************************************************80
%
%% prism_witherden_rule_test02() tests a rule of precision P.
%
%  Licensing:
%
%    This code is distributed under the GNU GPL license.
%
%  Modified:
%
%    17 May 2023
%
%  Author:
%
%    John Burkardt.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'pyramid_witherden_rule_test02():\n' );
  fprintf ( 1, '  Test the precision of a quadrature rule for the unit prism,\n' );

  dim_num = 3;
%
%  Retrieve the rule.
%
  [ n, x, y, z, w ] = prism_witherden_rule ( p );
%
%  Pack the x, y, z vectors as columns of an array.
%
  xyz = [ x', y', z' ];

  fprintf ( 1, '\n' );
  fprintf ( 1, '  Stated precision of rule    = %d\n', p );
  fprintf ( 1, '  Number of quadrature points = %d\n', n );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Degree  Maximum error\n' );
  fprintf ( 1, '\n' );

  for degree = 0 : p + 2

    expon = [];
    more = 0;
    h = 0;
    t = 0;
    max_error = 0.0;

    while ( true )

      [ expon, more, h, t ] = comp_next ( degree, dim_num, expon, more, h, t );

      v = monomial_value ( expon, xyz );

      quad = prism_unit_volume ( ) * dot ( w, v );

      exact = prism_unit_monomial_integral ( expon );

      quad_error = abs ( quad - exact );
      max_error = max ( max_error, quad_error );

      if ( ~ more )
        break
      end

    end

    fprintf ( 1, '  %2d  %24.16g\n', degree, max_error );

  end

  return
end
