d01ja 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 method can handle singularities on the surface or at the centre of the sphere, and returns an error estimate.
Syntax
C# |
---|
public static void d01ja( D01..::..D01JA_F f, int ndim, double radius, double epsa, double epsr, int method, int icoord, out double result, out double esterr, out int nevals, out int ifail ) |
Visual Basic |
---|
Public Shared Sub d01ja ( _ f As D01..::..D01JA_F, _ ndim As Integer, _ radius As Double, _ epsa As Double, _ epsr As Double, _ method As Integer, _ icoord As Integer, _ <OutAttribute> ByRef result As Double, _ <OutAttribute> ByRef esterr As Double, _ <OutAttribute> ByRef nevals As Integer, _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void d01ja( D01..::..D01JA_F^ f, int ndim, double radius, double epsa, double epsr, int method, int icoord, [OutAttribute] double% result, [OutAttribute] double% esterr, [OutAttribute] int% nevals, [OutAttribute] int% ifail ) |
F# |
---|
static member d01ja : f : D01..::..D01JA_F * ndim : int * radius : float * epsa : float * epsr : float * method : int * icoord : int * result : float byref * esterr : float byref * nevals : int byref * ifail : int byref -> unit |
Parameters
- f
- Type: NagLibrary..::..D01..::..D01JA_Ff must return the value of the integrand at a given point.
A delegate of type D01JA_F.
See also [Further Comments].
- ndim
- Type: System..::..Int32On entry: , the dimension of the sphere.Constraint: .
- radius
- Type: System..::..DoubleOn entry: , the radius of the sphere.Constraint: .
- epsa
- Type: System..::..DoubleOn entry: the requested absolute tolerance. If , its absolute value is used. See [Accuracy].
- epsr
- Type: System..::..DoubleOn entry: the requested relative tolerance.
- Its absolute value is used.
- The latter value is used as epsr by the method. See [Accuracy].
- method
- Type: System..::..Int32On entry: must specify the transformation to be used by the method. 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 icoord 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.
- 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 epsa and epsr to be , but the critical value will be smaller for a well-behaved integrand and larger for an integrand with severe singularities.Suggested value: .Constraint: , , , , , or .If , or
- icoord
- Type: System..::..Int32On entry: must specify which kind of coordinates are used in f.
- Cartesian coordinates , for .
- Spherical coordinates (see [Spherical Polar Coordinates]): ; , for .
- ,
- Special spherical polar coordinates (see [Machine Dependencies]), with the additional transformation : ; , for .
Constraint: , or .If or ,
- result
- Type: System..::..Double%On exit: the approximation to the integral .
- esterr
- Type: System..::..Double%On exit: an estimate of the modulus of the absolute error.
- nevals
- Type: System..::..Int32%On exit: the number of function evaluations used.
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
d01ja 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 method 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
Error Indicators and Warnings
Note: d01ja may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
- The required accuracy cannot be achieved within a limiting number of function evaluations (which is set by the method).
- The required accuracy cannot be achieved because of round-off error.
- The required accuracy cannot be achieved because the maximum accuracy with respect to the machine constants x02aj and x02am has been attained. If this maximum accuracy is rather low (compared with x02aj), the cause of the problem is a severe singularity on the boundary or at the centre of the sphere. If , or , then setting or may help.
On entry, or , or , or , , , , , or , or , or , or and or , or or and .
Accuracy
You can specify an absolute and/or a relative tolerance, setting epsa and epsr. The method attempts to calculate an approximation result such that
If ,
esterr returns an estimate of, but not necessarily a bound for, .
Parallelism and Performance
None.
Further Comments
Timing
Timing depends on the integrand and the accuracy required.
Spherical Polar Coordinates
Cartesian coordinates are related to the spherical polar coordinates by:
where , for and .
Machine Dependencies
As a consequence of the transformation technique, the severity of the singularities which can be handled by d01ja depends on the precision and range of real numbers on the machine. or must be used when the singularity on the surface is ‘severe’ in view of the requested accuracy and machine precision. In practice one has to set or if d01ja terminates with when called with , or .
When integrating a function with a severe singular behaviour on the surface of the sphere, the additional transformation helps to avoid the loss of significant figures due to round-off error in the calculation of the integration nodes which are very close to the surface. For these points, the value of can be computed more accurately than the value of . Naturally, care must be taken that the function subprogram does not contain expressions of the form , which could cause a large round-off error in the calculation of the integrand at the boundary of the sphere.
Care should be taken to avoid underflow and/or overflow problems in the function subprogram, because some of the integration nodes used by d01ja may be very close to the surface or to the centre of the sphere.
Example:
- suppose the function
is to be integrated over the unit sphere, with or . Then icoord should be set to 2; the transformation gives ; and f could be coded thus:
Note that d01ja ensures that , but underflow could occur in the computation of .
Example
This example evaluates the integrals
where , and is the unit sphere of dimension .
The exact values (to decimal places) are and .