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_prime (d01gy) calculates the optimal coefficients for use by nag_quad_md_numth (d01gc) and nag_quad_md_numth_vec (d01gd), for prime numbers of points.

Syntax

[vk, ifail] = d01gy(ndim, npts)

Description

The Korobov (1963) procedure for calculating the optimal coefficients ${a}_{1},{a}_{2},\dots ,{a}_{n}$ for $p$-point integration over the $n$-cube ${\left[0,1\right]}^{n}$ imposes the constraint that
 (1)
where $p$ is a prime number and $a$ is an adjustable argument. This argument is computed to minimize the error in the integral
 $3n∫01dx1⋯∫01dxn∏i=1n 1-2xi 2,$ (2)
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 $p$ is extremely time consuming (the number of elementary operations varying as ${p}^{2}$) and there is a practical upper limit to the number of points that can be used. Function nag_quad_md_numth_coeff_2prime (d01gz) is computationally more economical in this respect but the associated error is likely to be larger.

References

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

Parameters

Compulsory Input Parameters

1:     $\mathrm{ndim}$int64int32nag_int scalar
$n$, the number of dimensions of the integral.
Constraint: ${\mathbf{ndim}}\ge 1$.
2:     $\mathrm{npts}$int64int32nag_int scalar
$p$, the number of points to be used.
Constraint: ${\mathbf{npts}}$ must be a prime number $\text{}\ge 5$.

None.

Output Parameters

1:     $\mathrm{vk}\left({\mathbf{ndim}}\right)$ – double array
The $n$ optimal coefficients.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{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.

${\mathbf{ifail}}=1$
 On entry, ${\mathbf{ndim}}<1$.
${\mathbf{ifail}}=2$
 On entry, ${\mathbf{npts}}<5$.
${\mathbf{ifail}}=3$
 On entry, npts is not a prime number.
W  ${\mathbf{ifail}}=4$
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.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

Accuracy

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

The time taken is approximately proportional to ${p}^{2}$ (see Description).

Example

This example calculates the Korobov optimal coefficients where the number of dimensions is $4$ and the number of points is $631$.
function d01gy_example

fprintf('d01gy example results\n\n');

ndim = int64(4);
npts = int64(631);

[vk, ifail] = d01gy(ndim, npts);

fprintf('Optimal coefficients:');
fprintf('%6d',vk);
fprintf('\n');

d01gy example results

Optimal coefficients:     1   198    82   461