naginterfaces.library.quad.md_sphere(ndim, f, sigma, limit, region=None, r0=0.8, u=1.5, data=None)[source]

md_sphere calculates an approximation to a definite integral in up to dimensions, using the method of Sag and Szekeres (see Sag and Szekeres (1964)). The region of integration is an -sphere, or by built-in transformation via the unit -cube, any product region.

For full information please refer to the NAG Library document for d01fd

https://www.nag.com/numeric/nl/nagdoc_28.5/flhtml/d01/d01fdf.html

Parameters
ndimint

, the number of dimensions of the integral.

fcallable retval = f(x, data=None)

must return the value of the integrand at a given point.

Parameters
xfloat, ndarray, shape

The coordinates of the point at which the integrand must be evaluated.

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
retvalfloat

The value of evaluated at .

sigmafloat

Indicates the region of integration.

The integration is carried out over the -sphere of radius , centred at the origin.

The integration is carried out over the product region described by .

limitint

The approximate maximum number of integrand evaluations to be used.

regionNone or callable (c, d) = region(x, j, data=None), optional

Note: if this argument is None then a NAG-supplied facility will be used.

If , must evaluate the limits of integration in any dimension.

Parameters
xfloat, ndarray, shape

contain the current values of the first variables, which may be used if necessary in calculating and .

jint

The index for which the limits of the range of integration are required.

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
cfloat

The lower limit of the range of .

dfloat

The upper limit of the range of .

r0float, optional

The cut-off radius on the unit -sphere, which may be regarded as an adjustable parameter of the method.

ufloat, optional

Must specify an adjustable parameter of the transformation to the unit -sphere.

dataarbitrary, optional

User-communication data for callback functions.

Returns
resultfloat

The approximation to the integral .

ncallsint

The actual number of integrand evaluations used. (See also Further Comments.)

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

Notes

md_sphere calculates an approximation to

or, more generally,

where each and may be functions of .

The function uses the method of Sag and Szekeres (1964), which exploits a property of the shifted -point trapezoidal rule, namely, that it integrates exactly all polynomials of degree (see Krylov (1962)). An attempt is made to induce periodicity in the integrand by making a parameterised transformation to the unit -sphere. The Jacobian of the transformation and all its direct derivatives vanish rapidly towards the surface of the unit -sphere, so that, except for functions which have strong singularities on the boundary, the resulting integrand will be pseudo-periodic. In addition, the variation in the integrand can be considerably reduced, causing the trapezoidal rule to perform well.

Integrals of the form (1) are transformed to the unit -sphere by the change of variables:

where and is an adjustable parameter.

Integrals of the form (2) are first of all transformed to the -cube by a linear change of variables

and then to the unit sphere by a further change of variables

where and is again an adjustable parameter.

The parameter in these transformations determines how the transformed integrand is distributed between the origin and the surface of the unit -sphere. A typical value of is . For larger , the integrand is concentrated toward the centre of the unit -sphere, while for smaller it is concentrated toward the perimeter.

In performing the integration over the unit -sphere by the trapezoidal rule, a displaced equidistant grid of size is constructed. The points of the mesh lie on concentric layers of radius

The function requires you to specify an approximate maximum number of points to be used, and then computes the largest number of whole layers to be used, subject to an upper limit of layers.

In practice, the rapidly-decreasing Jacobian makes it unnecessary to include the whole unit -sphere and the integration region is limited by a user-specified cut-off radius . The grid-spacing is determined by and the number of layers to be used. A typical value of is .

Some experimentation may be required with the choice of (which determines how much of the unit -sphere is included) and (which determines how the transformed integrand is distributed between the origin and surface of the unit -sphere), to obtain best results for particular families of integrals. This matter is discussed further in Further Comments.

References

Krylov, V I, 1962, Approximate Calculation of Integrals, (trans A H Stroud), Macmillan

Sag, T W and Szekeres, G, 1964, Numerical evaluation of high-dimensional integrals, Math. Comput. (18), 245–253