# NINT_EXACTNESS_MIXED Exactness of Multidimensional Quadrature Using Mixed Rules

NINT_EXACTNESS_MIXED is a C++ program which investigates the polynomial exactness of a multidimensional quadrature rule which is designed for a quadrature region that is a direct product of 1D regions which are a mixture of Legendre, Laguerre, and Hermite type regions.

The six standard 1d quadrature problems that may be used as factors for the multidimensional problem are:

• Legendre integration
interval: [-1,+1],
weight: w(x) = 1,
rules: Clenshaw Curtis, Fejer Type 2, Gauss Legendre, Gauss Patterson.
• Jacobi integration:
interval: [-1,+1],
weight: w(x) = (1-x)^alpha (1+x)^beta.
rules: Gauss Jacobi.
• Laguerre integration
interval: [0,+oo),
weight: w(x) = exp(-x).
rules: Gauss Laguerre.
• Generalized Laguerre integration
interval: [0,+oo),
weight: w(x) = x^alpha exp(-x).
rules: Gauss Laguerre.
• Hermite integration
interval: (-oo,+oo),
weight: w(x) = exp(-x*x).
rules: Gauss Hermite.
• Generalized Hermite integration
interval: (-oo,+oo),
weight: w(x) = |x|^alpha exp(-x*x).
rules: generalized Gauss Hermite.

The M-dimensional quadrature region R based on mixed factors is formed by the direct product

R = R1 x R2 x ... x Rm
where each factor region Ri is the region associated with one of the six rules. Thus, R is a sort of generalized hyperrectangle, with the understanding that in some coordinate directions the region may be semi-infinite or infinite.

The M-dimensional weight function W based on mixed factors is formed by the dproduct

w(x1,x2,...xm) = w1(x1) x w2(x2) x ... x wm(xm)
where each factor weight wi(xi) is the weight function associated with one of the six rules. Some weight functions include parameters alpha and beta, and these parameters may be specified independently in each dimension.

For a quadrature region R based on mixed factors, the corresponding monomial integrand has the form

Mono(X,E) = X1^E1 x X2^E2 x ... x Xm^Em
where each exponent Ei is a nonnegative integer.

The total degree of a monomial Mono(X,E) is:

TotalDegree(Mono(X,E)) = Sum ( 1 <= I <= M ) E(I)

Thus, for instance, the total degree of

x12 * x2 * x35
is 2+1+5=8.

The corresponding monomial integral is:

Integral ( X in R ) Mono(X,E) W(X) dX
where each exponent Ei is a nonnegative integer.

The monomial exactness of a quadrature rule is the maximum number D such that, for every monomial of total degree D or less, the quadrature rule produces the exact value of the monomial integral.

The polynomial exactness of a quadrature rule is the maximum number D such that, for every polynomial of total degree D or less, the quadrature rule produces the exact value of the polynomial integral. The total degree of a polynomial is simply the maximum of the total degrees of the monomials that form the polynomial.

This program is given a quadrature rule based on mixed factors, and seeks to determine the polynomial exactness of the rule. It does this simply by applying the quadrature rule to all the monomials of a total degree 0 up to some limit specified by the user.

The program is very flexible and interactive. The quadrature rule is defined by five files, to be read at input, and the maximum degree is specified by the user as well.

The files that define the quadrature rule are assumed to have related names, of the form

• prefix_a.txt, the "ALPHA" file;
• prefix_b.txt, the "BETA" file;
• prefix_r.txt, the "REGION" file;
• prefix_w.txt, the "WEIGHT" file;
• prefix_x.txt, the "ABSCISSA" file.
When running the program, the user only enters the common prefix part of the file names, which is enough information for the program to find all the files.

### Usage:

nint_exactness_mixed prefix degree_max
where
• prefix is the common prefix for the files containing the alpha, beta, region, weight and abscissa information of the quadrature rule;
• degree_max is the maximum total monomial degree to check. This should be a relatively small nonnegative number, particularly if the spatial dimension is high. A value of 5 or 10 might be reasonable, but a value of 50 or 100 is probably never a good input!

If the arguments are not supplied on the command line, the program will prompt for them.

### Languages:

NINT_EXACTNESS_MIXED is available in a C++ version and a FORTRAN90 version and a MATLAB version.

### Related Data and Programs:

INT_EXACTNESS, a C++ program which tests the polynomial exactness of one dimensional quadrature rules.

NINT_EXACTNESS, a C++ program which tests the polynomial exactness of integration rules for the unit hypercube.

NINTLIB, a C++ library which numerically estimates integrals in multiple dimensions.

PYRAMID_EXACTNESS, a C++ program which investigates the polynomial exactness of a quadrature rule for the pyramid.

SPARSE_GRID_MIXED, a dataset directory which contains multidimensional Smolyak sparse grids based on a mixed set of 1D factor rules.

SPARSE_GRID_MIXED, a C++ library which defines multidimensional quadrature rules using sparse grid techniques, based on a mixed set of 1D quadrature rules.

SPHERE_EXACTNESS, a C++ program which tests the polynomial exactness of a quadrature rule for the unit sphere;

STROUD, a C++ library which defines quadrature rules for a variety of unusual areas, surfaces and volumes in 2D, 3D and multiple dimensions.

TEST_NINT, a C++ library which defines integrand functions for testing multidimensional quadrature routines.

TESTPACK, a C++ library which defines a set of integrands used to test multidimensional quadrature.

TETRAHEDRON_EXACTNESS, a C++ program which investigates the polynomial exactness of a quadrature rule for the tetrahedron.

### Reference:

1. Philip Davis, Philip Rabinowitz,
Methods of Numerical Integration,
Second Edition,
Dover, 2007,
ISBN: 0486453391,
LC: QA299.3.D28.

### Examples and Tests:

SPARSE_GRID_MIXED_D2_L2_CCXCC is a level 2 sparse grid quadrature rule for dimension 2, based on 1D factors of [Clenshaw Curtis, Clenshaw Curtis].

SPARSE_GRID_MIXED_D2_L2_CCXGL is a level 2 sparse grid quadrature rule for dimension 2, based on 1D factors of [Clenshaw Curtis, Gauss Legendre].

SPARSE_GRID_MIXED_D2_L2_CCXGLG is a level 2 sparse grid quadrature rule for dimension 2, based on 1D factors of [Clenshaw Curtis, Generalized Gauss Laguerre]. The Generalized Gauss Laguerre rule uses ALPHA = 1.5.

SPARSE_GRID_MIXED_D2_L2_CCXLG is a level 2 sparse grid quadrature rule for dimension 2, based on 1D factors of [Clenshaw Curtis, Gauss Laguerre].

SPARSE_GRID_MIXED_D2_L2_F2XGJ is a level 2 sparse grid quadrature rule for dimension 2, based on 1D factors of [Fejer Type 2, Gauss Jacobi]. The Gauss Jacobi rule uses ALPHA = 0.5, BETA = 1.5.

SPARSE_GRID_MIXED_D2_L3_CCXGP is a level 3 sparse grid quadrature rule for dimension 2, based on 1D factors of [Clenshaw Curtis, Gauss Patterson].

SPARSE_GRID_MIXED_D3_L2_CCXF2XGH is a level 2 sparse grid quadrature rule for dimension 3, based on 1D factors of [Clenshaw Curtis, Fejer Type 2, Gauss Hermite].

### List of Routines:

• MAIN is the main program for NINT_EXACTNESS_MIXED.
• CH_CAP capitalizes a single character.
• CH_EQI is true if two characters are equal, disregarding case.
• CH_TO_DIGIT returns the integer value of a base 10 digit.
• COMP_NEXT computes the compositions of the integer N into K parts.
• FILE_COLUMN_COUNT counts the columns in the first line of a file.
• FILE_ROW_COUNT counts the number of row records in a file.
• MONOMIAL_INTEGRAL_GENERALIZED_HERMITE evaluates a 1D monomial generalized Hermite integral.
• MONOMIAL_INTEGRAL_GENERALIZED_LAGUERRE evaluates a 1D monomial generalized Laguerre integral.
• MONOMIAL_INTEGRAL_HERMITE evaluates a 1D monomial Hermite integral.
• MONOMIAL_INTEGRAL_JACOBI evaluates the integral of a monomial with Jacobi weight.
• MONOMIAL_INTEGRAL_LAGUERRE evaluates a 1D monomial Laguerre integral.
• MONOMIAL_INTEGRAL_LEGENDRE evaluates a 1D monomial Legendre integral.
• MONOMIAL_INTEGRAL_MIXED evaluates a multi-D monomial mixed integral.
• MONOMIAL_VALUE evaluates a monomial.
• R8_ABS returns the absolute value of an R8.
• R8_FACTORIAL computes the factorial of N.
• R8_FACTORIAL2 computes the double factorial function.
• R8_GAMMA evaluates Gamma(X) for a real argument.
• R8_HUGE returns a "huge" R8.
• R8_HYPER_2F1 evaluates the hypergeometric function F(A,B,C,X).
• R8_PSI evaluates the function Psi(X).