naginterfaces.library.quad.md_​sphere_​bad

naginterfaces.library.quad.md_sphere_bad(f, ndim, radius, epsa, epsr, icoord, method=0, data=None)[source]

md_sphere_bad attempts to evaluate an integral over an -dimensional sphere (, , or ), to a user-specified absolute or relative accuracy, by means of a modified Sag–Szekeres method. The function can handle singularities on the surface or at the centre of the sphere, and returns an error estimate.

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

https://support.nag.com/numeric/nl/nagdoc_30.3/flhtml/d01/d01jaf.html

Parameters
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. These coordinates are given in Cartesian or spherical polar form according to the value of .

dataarbitrary, optional, modifiable in place

User-communication data for callback functions.

Returns
retvalfloat

The value of evaluated at .

ndimint

, the dimension of the sphere.

radiusfloat

, the radius of the sphere.

epsafloat

The requested absolute tolerance. If , its absolute value is used. See Accuracy.

epsrfloat

The requested relative tolerance.

Its absolute value is used.

The latter value is used as by the function. See Accuracy.

icoordint

Must specify which kind of coordinates are used in .

Cartesian coordinates , for .

Spherical coordinates (see Further Comments): ; , for .

,

Special spherical polar coordinates (see Machine Dependencies), with the additional transformation : ; , for .

methodint, optional

Must specify the transformation to be used by the function. The choice depends on the behaviour of the integrand and on the required accuracy.

For well-behaved functions and functions with mild singularities on the surface of the sphere only:

Low accuracy required.

High accuracy required.

For functions with severe singularities on the surface of the sphere only:

Low accuracy required.

High accuracy required.

(in this case must be set to , and the function defined in special spherical coordinates).

For functions with a singularity at the centre of the sphere (and possibly with singularities on the surface as well):

Low accuracy required.

High accuracy required.

can be used as a default value and is equivalent to:

if , and

if .

The distinction between low and high required accuracies, as mentioned above, depends also on the behaviour of the function.

Roughly one may assume the critical value of and to be , but the critical value will be smaller for a well-behaved integrand and larger for an integrand with severe singularities.

dataarbitrary, optional

User-communication data for callback functions.

Returns
resultfloat

The approximation to the integral .

esterrfloat

An estimate of the modulus of the absolute error.

nevalsint

The number of function evaluations used.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: when , .

(errno )

On entry, and .

Constraint: when , .

(errno )

On entry, and .

Constraint: when , or .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )

The required accuracy could not be achieved.

(errno )

The required accuracy could not be achieved.

(errno )

The required accuracy could not be achieved.

If , or , setting or may help.

Notes

No equivalent traditional C interface for this routine exists in the NAG Library.

md_sphere_bad calculates an approximation to the -dimensional integral

where is the hypersphere

(the integrand function may also be defined in spherical coordinates). The algorithm is based on the Sag–Szekeres method (see Sag and Szekeres (1964)), applying the product trapezoidal formula after a suitable radial transformation. An improved transformation technique is developed: depending on the behaviour of the function and on the required accuracy, different transformations can be used, some of which are ‘double exponential’, as defined by Takahasi and Mori (1974). The resulting technique allows the function to deal with integrand singularities on the surface or at the centre of the sphere. When the estimated error of the approximation with mesh size is larger than the tolerated error, the trapezoidal formula with mesh size is calculated. A drawback of this method is the exponential growth of the number of function evaluations in the successive approximations (this number grows with a factor ). This introduces the restriction . Because the convergence rate of the successive approximations is normally better than linear, the error estimate is based on the linear extrapolation of the difference between the successive approximations (see Robinson and de Doncker (1981) and Roose and de Doncker (1981)). For further details of the algorithm, see Roose and de Doncker (1981).

References

Robinson, I and de Doncker, E, 1981, Automatic computation of improper integrals over a bounded or unbounded planar region, Computing (27), 89–284

Roose, D and de Doncker, E, 1981, Automatic integration over a sphere, J. Comput. Appl. Math. (7), 203–224

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

Takahasi, H and Mori, M, 1974, Double Exponential Formulas for Numerical Integration (9), Publ. RIMS, Kyoto University, 721–741