# PRODUCT_RULE Multidimensional Quadrature Rule Creation

PRODUCT_RULE is a C program which creates a multidimensional quadrature rule by using a product of distinct one-dimensional quadrature rules.

The program reads a single input file, which contains a list that defines the 1D rules to be used as factors.

Each 1D rule is stored in three files, an "X", "W", and "R" file, which are assumed to share a common filename prefix, so that the files defined by a given prefix have the form:

• prefix_x.txt
• prefix_w.txt
• prefix_r.txt

For instance, let us suppose we want to compute a 2D product rule formed from a 3 point Clenshaw Curtis rule and a 2 point Gauss-Legendre rule. If the prefixes for these files were "cc_d1_o003" and "gl_d1_o002" respectively, then the input file to the program would read as follows:

```        cc_d1_o003
gl_d1_o002
```
When the program read the first 1D rule, it would be searching for three files:
• cc_d1_o003_x.txt
• cc_d1_o003_w.txt
• cc_d1_o003_r.txt
and similarly for the second file.

Once the program has computed the multidimensional product rule, it again writes out three files describing the product rule, with a common filename prefix specified by the user, which might be, for instance, product, in which case the files would be:

• product_x.txt
• product_w.txt
• product_r.txt

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

### Usage:

product_rule ( list_file, product_prefix )
where
• list_file is the name of the file containing the list of filename prefixes that can be used to locate the X, W and R files of each 1D quadrature rule.
• product_prefix is the prefix to be used when writing out the X, W and R files of the computed multidimensional product rule.

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

### Languages:

PRODUCT_RULE is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version

### Related Data and Programs:

CLENSHAW_CURTIS_RULE, a C program which defines a Clenshaw Curtis quadrature rule.

HERMITE_RULE, a C program which can compute and print a Gauss-Hermite quadrature rule.

LEGENDRE_RULE, a C program which computes a 1D Gauss-Legendre quadrature rule.

POWER_RULE, a C program which constructs a power rule, that is, a product quadrature rule from identical 1D factor rules.

QUADRULE, a C library which defines quadrature rules on a variety of intervals with different weight functions.

TRUNCATED_NORMAL_RULE, a C program which computes a quadrature rule for a normal probability density function (PDF), also called a Gaussian distribution, that has been truncated to [A,+oo), (-oo,B] or [A,B].

### Reference:

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

### Examples and Tests:

As an example, we make a 2D product rule.

The first factor is a 1D Clenshaw Curtis rule of order 3:

The second factor is a 1D Gauss Legendre rule of order 2:

We give the command

product_rule factors.txt

The resulting product rule files:

### List of Routines:

• MAIN is the main program for PRODUCT_RULE.
• 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.
• 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.
• PRODUCT_RULE_SIZE returns the size of a product rule of distinct factors.
• R8_EPSILON returns the R8 roundoff unit.
• R8MAT_WRITE writes an R8MAT file with no header.
• R8VEC_DIRECT_PRODUCT creates a direct product of R8VEC's.
• R8VEC_DIRECT_PRODUCT2 creates a direct product of R8VEC's.
• S_LEN_TRIM returns the length of a string to the last nonblank.
• 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 C source codes.

Last revised on 15 February 2014.