Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

Purpose

nag_quad_md_numth_coeff_2prime (d01gz) calculates the optimal coefficients for use by nag_quad_md_numth (d01gc) and nag_quad_md_numth_vec (d01gd), when the number of points is the product of two primes.

Syntax

[vk, ifail] = d01gz(ndim, np1, np2)
[vk, ifail] = nag_quad_md_numth_coeff_2prime(ndim, np1, np2)

Description

Korobov (1963) gives a procedure for calculating optimal coefficients for p$p$-point integration over the n$n$-cube [0,1]n${\left[0,1\right]}^{n}$, when the number of points is
 p = p1p2 $p=p1p2$ (1)
where p1${p}_{1}$ and p2${p}_{2}$ are distinct prime numbers.
The advantage of this procedure is that if p1${p}_{1}$ is chosen to be the nearest prime integer to p22${p}_{2}^{2}$, then the number of elementary operations required to compute the rule is of the order of p4 / 3${p}^{4/3}$ which grows less rapidly than the number of operations required by nag_quad_md_numth_coeff_prime (d01gy). The associated error is likely to be larger although it may be the only practical alternative for high values of p$p$.

References

Korobov N M (1963) Number Theoretic Methods in Approximate Analysis Fizmatgiz, Moscow

Parameters

Compulsory Input Parameters

1:     ndim – int64int32nag_int scalar
n$n$, the number of dimensions of the integral.
Constraint: ndim1${\mathbf{ndim}}\ge 1$.
2:     np1 – int64int32nag_int scalar
The larger prime factor p1${p}_{1}$ of the number of points in the integration rule.
Constraint: np1${\mathbf{np1}}$ must be a prime number 5$\text{}\ge 5$.
3:     np2 – int64int32nag_int scalar
The smaller prime factor p2${p}_{2}$ of the number of points in the integration rule. For maximum efficiency, p22${p}_{2}^{2}$ should be close to p1${p}_{1}$.
Constraint: np2${\mathbf{np2}}$ must be a prime number such that np1 > np22${\mathbf{np1}}>{\mathbf{np2}}\ge 2$.

None.

None.

Output Parameters

1:     vk(ndim) – double array
The n$n$ optimal coefficients.
2:     ifail – int64int32nag_int scalar
${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

ifail = 1${\mathbf{ifail}}=1$
 On entry, ndim < 1${\mathbf{ndim}}<1$.
ifail = 2${\mathbf{ifail}}=2$
 On entry, np1 < 5${\mathbf{np1}}<5$, or np2 < 2${\mathbf{np2}}<2$, or ${\mathbf{np1}}\le {\mathbf{np2}}$.
ifail = 3${\mathbf{ifail}}=3$
The value ${\mathbf{np1}}×{\mathbf{np2}}$ exceeds the largest integer representable on the machine, and hence the optimal coefficients could not be used in a valid call of nag_quad_md_numth (d01gc) or nag_quad_md_numth_vec (d01gd).
ifail = 4${\mathbf{ifail}}=4$
 On entry, np1 is not a prime number.
ifail = 5${\mathbf{ifail}}=5$
 On entry, np2 is not a prime number.
W ifail = 6${\mathbf{ifail}}=6$
The precision of the machine is insufficient to perform the computation exactly. Try smaller values of np1 or np2, or use an implementation with higher precision.

Accuracy

The optimal coefficients are returned as exact integers (though stored in a double array).

The time taken by nag_quad_md_numth_coeff_2prime (d01gz) grows at least as fast as (p1p2)4 / 3${\left({p}_{1}{p}_{2}\right)}^{4/3}$. (See Section [Description].)

Example

```function nag_quad_md_numth_coeff_2prime_example
ndim = int64(4);
np1 = int64(89);
np2 = int64(11);
[vk, ifail] = nag_quad_md_numth_coeff_2prime(ndim, np1, np2)
```
```

vk =

1
102
614
951

ifail =

0

```
```function d01gz_example
ndim = int64(4);
np1 = int64(89);
np2 = int64(11);
[vk, ifail] = d01gz(ndim, np1, np2)
```
```

vk =

1
102
614
951

ifail =

0

```