NAG Library Routine Document
D01GZF calculates the optimal coefficients for use by
when the number of points is the product of two primes.
||NDIM, NP1, NP2, IFAIL
gives a procedure for calculating optimal coefficients for
-point integration over the
, when the number of points is
are distinct prime numbers.
The advantage of this procedure is that if
is chosen to be the nearest prime integer to
, then the number of elementary operations required to compute the rule is of the order of
which grows less rapidly than the number of operations required by D01GYF
. The associated error is likely to be larger although it may be the only practical alternative for high values of
Korobov N M (1963) Number Theoretic Methods in Approximate Analysis Fizmatgiz, Moscow
- 1: NDIM – INTEGERInput
On entry: , the number of dimensions of the integral.
- 2: NP1 – INTEGERInput
On entry: the larger prime factor of the number of points in the integration rule.
must be a prime number .
- 3: NP2 – INTEGERInput
On entry: the smaller prime factor of the number of points in the integration rule. For maximum efficiency, should be close to .
must be a prime number such that .
- 4: VK(NDIM) – REAL (KIND=nag_wp) arrayOutput
On exit: the optimal coefficients.
- 5: IFAIL – INTEGERInput/Output
must be set to
. If you are unfamiliar with this parameter you should refer to Section 3.3
in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
. When the value is used it is essential to test the value of IFAIL on exit.
unless the routine detects an error or a warning has been flagged (see Section 6
6 Error Indicators and Warnings
If on entry
, explanatory error messages are output on the current error message unit (as defined by X04AAF
Errors or warnings detected by the routine:
exceeds the largest integer representable on the machine, and hence the optimal coefficients could not be used in a valid call of D01GCF
|On entry,||NP1 is not a prime number.|
|On entry,||NP2 is not a prime number.|
The precision of the machine is insufficient to perform the computation exactly. Try smaller values of NP1
, or use an implementation with higher precision.
The optimal coefficients are returned as exact integers (though stored in a real array).
The time taken by D01GZF grows at least as fast as
. (See Section 3
This example calculates the Korobov optimal coefficients where the number of dimensons is and the number of points is the product of the two prime numbers, and .
9.1 Program Text
Program Text (d01gzfe.f90)
9.2 Program Data
9.3 Program Results
Program Results (d01gzfe.r)