NAG Library Routine Document
D01GYF calculates the optimal coefficients for use by
for prime numbers of points.
||NDIM, NPTS, IFAIL
The Korobov (1963)
procedure for calculating the optimal coefficients
-point integration over the
imposes the constraint that
is a prime number and
is an adjustable parameter. This parameter is computed to minimize the error in the integral
when computed using the number theoretic rule, and the resulting coefficients can be shown to fit the Korobov definition of optimality.
The computation for large values of
is extremely time consuming (the number of elementary operations varying as
) and there is a practical upper limit to the number of points that can be used. Routine D01GZF
is computationally more economical in this respect but the associated error is likely to be larger.
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: NPTS – INTEGERInput
On entry: , the number of points to be used.
must be a prime number .
- 3: VK(NDIM) – REAL (KIND=nag_wp) arrayOutput
On exit: the optimal coefficients.
- 4: 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:
|On entry,||NPTS is not a prime number.|
The precision of the machine is insufficient to perform the computation exactly. Try a smaller value of NPTS
, or use an implementation of higher precision.
The optimal coefficients are returned as exact integers (though stored in a real array).
The time taken is approximately proportional to
(see Section 3
This example calculates the Korobov optimal coefficients where the number of dimensions is and the number of points is .
9.1 Program Text
Program Text (d01gyfe.f90)
9.2 Program Data
9.3 Program Results
Program Results (d01gyfe.r)