# INT_EXACTNESS_HERMITE Exactness of Gauss-Hermite Quadrature Rules

INT_EXACTNESS_HERMITE is a FORTRAN90 program which investigates the polynomial exactness of a Gauss-Hermite quadrature rule for the infinite interval (-oo,+oo).

The Gauss Hermite quadrature assumes that the integrand we are considering has a form like:

```        Integral ( -oo < x < +oo ) w(x) * f(x) dx
```
where the factor w(x) is regarded as a weight factor.

We consider three variations of the rule, depending on the form of the weight factor w(x):

• option = 0, the unweighted rule:
```            Integral ( -oo < x < +oo ) f(x) dx
```
• option = 1, the physicist weighted rule:
```            Integral ( -oo < x < +oo ) exp(-x*x) f(x) dx
```
• option = 2, the probabilist weighted rule:
```            Integral ( -oo < x < +oo ) exp(-x*x/2) f(x) dx
```

The corresponding Gauss-Hermite rule that uses order points will approximate the integral by

```        sum ( 1 <= i <= order ) w(i) * f(x(i))
```
where, confusingly, w(i) is a vector of quadrature weights, which has no connection with the w(x) weight function.

When using a Gauss-Hermite quadrature rule, it's important to know whether the rule has been developed for the unweighted, physicist weighted or probabilist weighted cases.

For an unweighted Gauss-Hermite rule, polynomial exactness may be defined by assuming that f(x) has the form f(x) = exp(-x*x) * x^n for some nonnegative integer exponent n. We say an unweighted Gauss-Hermite rule is exact for polynomials up to degree DEGREE_MAX if the quadrature rule will produce the correct value of the integrals of such integrands for all exponents n from 0 to DEGREE_MAX.

For a physicist or probabilist weighted Gauss-Hermite rules, polynomial exactness may be defined by assuming that f(x) has the form f(x) = x^n for some nonnegative integer exponent n. We say the physicist or probabilist weighted Gauss-Hermite rule is exact for polynomials up to degree DEGREE_MAX if the quadrature rule will produce the correct value of the integrals of such integrands for all exponents n from 0 to DEGREE_MAX.

To test the polynomial exactness of a Gauss-Hermite quadrature rule of one of these three forms, the program starts at n = 0, and then proceeds to n = 1, 2, and so on up to a maximum degree DEGREE_MAX specified by the user. At each value of n, the program generates the appropriate corresponding integrand function (either exp(-x*x)*x^n or x^n), applies the quadrature rule to it, and determines the quadrature error. The program uses a scaling factor on each monomial so that the exact integral should always be 1; therefore, each reported error can be compared on a fixed scale.

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

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

• prefix_x.txt
• prefix_w.txt
• prefix_r.txt
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 three files.

Note that when approximating these kinds of integrals, or even when evaluating an exact formula for these integrals, numerical inaccuracies can become overwhelming. The formula for the exact integral of x^n*exp(-x*x) (which we use to test for polynomial exactness) involves the double factorial function, which "blows up" almost as fast as the ordinary factorial. Thus, even for formulas of order 16, where we would like to consider monomials up to degree 31, the evaluation of the exact formula loses significant accuracy.

For information on the form of these files, see the QUADRATURE_RULES_HERMITE directory listed below.

The exactness results are written to an output file with the corresponding name:

• prefix_exact.txt

### Usage:

int_exactness_hermite prefix degree_max option
where
• prefix is the common prefix for the files containing the abscissa, weight and region information of the quadrature rule;
• degree_max is the maximum monomial degree to check. This would normally be a relatively small nonnegative number, such as 5, 10 or 15.
• option:
0 indicates the unweighted rule for integrating f(x),
1 indicates the physicist weighted rule for integrating exp(-x*x)*f(x),
2 indicates the probabilist weighted rule for integrating exp(-x*x/2)*f(x).

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

### Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

### Languages:

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

### Related Data and Programs:

HERMITE_RULE, a FORTRAN90 program which generates a Gauss-Hermite quadrature rule on request.

INT_EXACTNESS, a FORTRAN90 program which tests the polynomial exactness of a quadrature rule for a finite interval.

INT_EXACTNESS_CHEBYSHEV1, a FORTRAN90 program which tests the polynomial exactness of Gauss-Chebyshev type 1 quadrature rules.

INT_EXACTNESS_CHEBYSHEV2, a FORTRAN90 program which tests the polynomial exactness of Gauss-Chebyshev type 2 quadrature rules.

INT_EXACTNESS_GEGENBAUER, a FORTRAN90 program which tests the polynomial exactness of Gauss-Gegenbauer quadrature rules.

INT_EXACTNESS_GEN_HERMITE, a FORTRAN90 program which tests the polynomial exactness of generalized Gauss-Hermite quadrature rules.

INT_EXACTNESS_GEN_LAGUERRE, a FORTRAN90 program which tests the polynomial exactness of generalized Gauss-Laguerre quadrature rules.

INT_EXACTNESS_JACOBI, a FORTRAN90 program which tests the polynomial exactness of Gauss-Jacobi quadrature rules.

INT_EXACTNESS_LAGUERRE, a FORTRAN90 program which tests the polynomial exactness of Gauss-Laguerre quadrature rules.

INT_EXACTNESS_LEGENDRE, a FORTRAN90 program which tests the polynomial exactness of Gauss-Legendre quadrature rules.

QUADRATURE_RULES, a dataset directory which contains sets of files that define quadrature rules over various 1D intervals or multidimensional hypercubes.

QUADRATURE_RULES_HERMITE_PHYSICIST, a dataset directory which contains Gauss-Hermite quadrature rules, for integration on the interval (-oo,+oo), with weight function exp(-x^2).

QUADRATURE_RULES_HERMITE_PROBABILIST, a dataset directory which contains Gauss-Hermite quadrature rules, for integration on the interval (-oo,+oo), with weight function exp(-x^2/2).

QUADRATURE_RULES_HERMITE_UNWEIGHTED, a dataset directory which contains Gauss-Hermite quadrature rules, for integration on the interval (-oo,+oo), with weight function 1.

R16_HERMITE_RULE, a FORTRAN90 program which can compute and print a Gauss-Hermite quadrature rule, using "quadruple precision real" arithmetic.

TEST_INT_HERMITE, a FORTRAN90 library which defines integrand functions that can be approximately integrated by a Gauss-Hermite rule.

### Reference:

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

### List of Routines:

• MAIN is the main program for INT_EXACTNESS_HERMITE.
• CH_CAP capitalizes a single character.
• CH_EQI is a case insensitive comparison of two characters for equality.
• CH_TO_DIGIT returns the integer value of a base 10 digit.
• FILE_COLUMN_COUNT counts the number of columns in the first line of a file.
• FILE_ROW_COUNT counts the number of row records in a file.
• GET_UNIT returns a free FORTRAN unit number.
• HERMITE_INTEGRAL evaluates a monomial Hermite integral.
• MONOMIAL_QUADRATURE_HERMITE applies a quadrature rule to a monomial.
• R8_FACTORIAL2 computes the double factorial function N!!
• R8MAT_DATA_READ reads data from an R8MAT file.
• S_TO_I4 reads an I4 from a string.
• S_TO_R8 reads an R8 from a string.
• S_TO_R8VEC reads an R8VEC from a string.
• S_WORD_COUNT counts the number of "words" in a string.
• TIMESTAMP prints the current YMDHMS date as a time stamp.

You can go up one level to the FORTRAN90 source codes.

Last revised on 20 May 2009.