d01gd Method
関数リスト一覧   NagLibrary Namespaceへ  ライブラリイントロダクション  本ヘルプドキュメントのchm形式版

d01gd calculates an approximation to a definite integral in up to 20 dimensions, using the Korobov–Conroy number theoretic method. This method is designed to be particularly efficient on vector processors.

Syntax

C#
public static void d01gd(
	int ndim,
	D01..::.D01GD_VECFUN vecfun,
	D01..::.D01GD_VECREG vecreg,
	int npts,
	double[] vk,
	int nrand,
	int itrans,
	out double res,
	out double err,
	out int ifail
)
Visual Basic (Declaration)
Public Shared Sub d01gd ( _
	ndim As Integer, _
	vecfun As D01..::.D01GD_VECFUN, _
	vecreg As D01..::.D01GD_VECREG, _
	npts As Integer, _
	vk As Double(), _
	nrand As Integer, _
	itrans As Integer, _
	<OutAttribute> ByRef res As Double, _
	<OutAttribute> ByRef err As Double, _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void d01gd(
	int ndim, 
	D01..::.D01GD_VECFUN^ vecfun, 
	D01..::.D01GD_VECREG^ vecreg, 
	int npts, 
	array<double>^ vk, 
	int nrand, 
	int itrans, 
	[OutAttribute] double% res, 
	[OutAttribute] double% err, 
	[OutAttribute] int% ifail
)
F#
static member d01gd : 
        ndim:int * 
        vecfun:D01..::.D01GD_VECFUN * 
        vecreg:D01..::.D01GD_VECREG * 
        npts:int * 
        vk:float[] * 
        nrand:int * 
        itrans:int * 
        res:float byref * 
        err:float byref * 
        ifail:int byref -> unit 

Parameters

ndim
Type: System..::.Int32
On entry: n, the number of dimensions of the integral.
Constraint: 1ndim20.
vecfun
Type: NagLibrary..::.D01..::.D01GD_VECFUN
vecfun must evaluate the integrand at a specified set of points.

A delegate of type D01GD_VECFUN.

vecreg
Type: NagLibrary..::.D01..::.D01GD_VECREG
vecreg must evaluate the limits of integration in any dimension for a set of points.

A delegate of type D01GD_VECREG.

npts
Type: System..::.Int32
On entry: the Korobov rule to be used. There are two alternatives depending on the value of npts.
(i) 1npts6.
In this case one of six preset rules is chosen using 2129, 5003, 10007, 20011, 40009 or 80021 points depending on the respective value of npts being 1, 2, 3, 4, 5 or 6.
(ii) npts>6.
npts is the number of actual points to be used with corresponding optimal coefficients supplied in the array vk.
Constraint: npts1.
vk
Type: array< System..::.Double >[]()[]
An array of size [ndim]
On entry: if npts>6, vk must contain the n optimal coefficients (which may be calculated using d01gy or d01gz).
If npts6, vk need not be set.
On exit: if npts>6, vk is unchanged.
If npts6, vk contains the n optimal coefficients used by the preset rule.
nrand
Type: System..::.Int32
On entry: the number of random samples to be generated (generally a small value, say 3 to 5, is sufficient). The estimate, res, of the value of the integral returned by the method is then the average of nrand calculations with different random origin shifts. If npts>6, the total number of integrand evaluations will be nrand×npts. If 1npts6, then the number of integrand evaluations will be nrand×p, where p is the number of points corresponding to the six preset rules. For reasons of efficiency, these values are calculated a number at a time in vecfun.
Constraint: nrand1.
itrans
Type: System..::.Int32
On entry: indicates whether the periodising transformation is to be used.
itrans=0
The transformation is to be used.
itrans0
The transformation is to be suppressed (to cover cases where the integrand may already be periodic or where you want to specify a particular transformation in the definition of vecfun).
Suggested value: itrans=0.
res
Type: System..::.Double %
On exit: the approximation to the integral I.
err
Type: System..::.Double %
On exit: the standard error as computed from nrand sample values. If nrand=1, then err contains zero.
ifail
Type: System..::.Int32 %
On exit: ifail=0 unless the method detects an error (see [Error Indicators and Warnings]).

Description

d01gd calculates an approximation to the integral using the Korobov–Conroy number theoretic method (see Korobov (1957), Korobov (1963) and Conroy (1967)). The region of integration defined in (1) is such that generally ci  and di  may be functions of x1 , x2 ,, xi-1 , for i= 2 , 3 ,, n , with c1  and d1  constants. The integral is first of all transformed to an integral over the n-cube 0,1 n  by the change of variables
xi = ci + di - ci yi ,   i= 1 , 2 ,, n .
The method then uses as its basis the number theoretic formula for the n-cube, 0,1 n : where x  denotes the fractional part of x, a1 ,, an  are the so-called optimal coefficients, E is the error, and p is a prime integer. (It is strictly only necessary that p be relatively prime to all a1 ,, an  and is in fact chosen to be even for some cases in Conroy (1967).) The method makes use of properties of the Fourier expansion of g x1,,xn  which is assumed to have some degree of periodicity. Depending on the choice of a1 ,, an  the contributions from certain groups of Fourier coefficients are eliminated from the error, E. Korobov shows that a1 ,, an  can be chosen so that the error satisfies where α and C are real numbers depending on the convergence rate of the Fourier series, β is a constant depending on n, and K is a constant depending on α and n. There are a number of procedures for calculating these optimal coefficients. Korobov imposes the constraint that and gives a procedure for calculating the parameter, a, to satisfy the optimal conditions.
An easily calculable error estimate is not available apart from repetition with an increasing sequence of values of p which can yield erratic results. The difficulties have been studied by Cranley and Patterson (1976) who have proposed a Monte–Carlo error estimate arising from converting (2) into a stochastic integration rule by the inclusion of a random origin shift which leaves the form of the error (3) unchanged; i.e., in the formula (2), k ai p  is replaced by αi+k ai p , for i= 1 , 2 ,, n , where each αi , is uniformly distributed over 0,1 . Computing the integral for each of a sequence of random vectors α allows a ‘standard error’ to be estimated.
This method provides built-in sets of optimal coefficients, corresponding to six different values of p. Alternatively, the optimal coefficients may be supplied by you. Methods d01gy and d01gz compute the optimal coefficients for the cases where p is a prime number or p is a product of two primes, respectively.
This method is designed to be particularly efficient on vector processors, although it is very important that you also code vecfun and vecreg efficiently.

References

Error Indicators and Warnings

Accuracy

Further Comments

The exact values of res and err on return will depend (within statistical limits) on the sequence of random numbers generated within d01gd by calls to g05sa. Separate runs will produce identical answers.

Example

See Also