naginterfaces.library.quad.dim1_gen_vec_multi_rcomm¶
- naginterfaces.library.quad.dim1_gen_vec_multi_rcomm(irevcm, a, b, needi, x, nx, fm, dinest, errest, comm)[source]¶
dim1_gen_vec_multi_rcomm
is a general purpose adaptive integrator which calculates an approximation to a vector of definite integrals over a finite range , given the vector of integrands .If the same subdivisions of the range are equally good for functions and , because and have common areas of the range where they vary slowly and where they vary quickly, then we say that and are ‘similar’.
dim1_gen_vec_multi_rcomm
is particularly effective for the integration of a vector of similar functions.For full information please refer to the NAG Library document for d01ra
https://www.nag.com/numeric/nl/nagdoc_28.5/flhtml/d01/d01raf.html
- Parameters
- irevcmint
On initial entry: .
Sets up data structures in [‘icom’] and [‘com’] and starts a new integration.
On intermediate entry: should normally be left unchanged. However, if is set to a negative value,
dim1_gen_vec_multi_rcomm
will terminate, (see and above).- afloat
, the lower bound of the domain.
- bfloat
, the upper bound of the domain.
If , where is the machine precision (see
machine.precision
),dim1_gen_vec_multi_rcomm
will return , for .- neediint, ndarray, shape , modified in place
On initial entry: need not be set.
On intermediate exit: indicates what action must be taken for integral (see ).
Do not provide . Any provided values will be ignored.
The values must be provided in , for .
The values are not required, however the error estimate for integral is still above the requested tolerance. If you wish to provide values for the evaluation of integral , set , and supply in , for .
The error estimate for integral cannot be improved to below the requested tolerance directly, either because no more new splits may be performed due to exhaustion, or due to the detection of extremely bad integrand behaviour. However, providing the values may still lead to some improvement, and may lead to an acceptable error estimate indirectly using Wynn’s epsilon algorithm. If you wish to provide values for the evaluation of integral , set , and supply in , for .
The error estimate of integral is below the requested tolerance. If you believe this to be false, if for example the result in is greatly different to what you may expect, you may force the algorithm to re-evaluate this conclusion by including the evaluations of integrand at , for , and setting . Integral and error estimation will be performed again during the next iteration.
On intermediate entry: may be used to indicate what action you have taken for integral .
You have provided the values in , for .
You are abandoning the evaluation of integral . The current values of and will be returned on final completion.
Otherwise you have not provided the value .
On final exit: indicates the final state of integral .
The error estimate for is below the requested tolerance.
The error estimate for is below the requested tolerance after extrapolation.
The error estimate for is above the requested tolerance.
The error estimate for is above the requested tolerance, and extremely bad behaviour of integral has been detected.
You prohibited further evaluation of integral .
- xfloat, ndarray, shape , modified in place
On initial entry: if , need not be set. This is the default behaviour.
If , is used to supply a set of initial ‘break-points’ inside the domain of integration.
Specifically, must contain a break-point , for , where is the number of ‘Primary Divisions’.
On intermediate exit: is the abscissa , for , at which the appropriate integrals must be evaluated.
- nxint
On initial entry: need not be set.
On intermediate entry: must not be changed.
- fmfloat, array-like, shape
On initial entry: need not be set.
On intermediate entry: if indicated by you must supply the values in , for , for .
- dinestfloat, ndarray, shape , modified in place
contains the current estimate of the definite integral .
On initial entry: need not be set.
On intermediate entry: must not be altered.
On exit: contains the current estimates of the integrals. If , this will be the final solution.
- errestfloat, ndarray, shape , modified in place
contains the current error estimate of the definite integral .
On initial entry: need not be set.
On intermediate entry: must not be altered.
On exit: contains the current error estimates for the integrals. If , contains the final error estimates of the integrals.
- commdict, communication object, modified in place
Communication structure.
This argument must have been initialized by a prior call to
opt_set()
.
- Returns
- irevcmint
On intermediate exit: or .
requests the integrands be evaluated for all required as indicated by , and at all the points , for .
Abscissae are provided in and must be returned in .
During the initial solve phase:
Function values are required to construct the initial estimates of the definite integrals.
If , must be supplied in .
This will be the case unless you have abandoned the evaluation of specific integrals on a previous call.
If , you have previously abandoned the evaluation of integral , and hence should not supply the value of .
and contain incomplete information during this phase.
As such you should not abandon the evaluation of any integrals during this phase unless you do not require their estimate.
If is set to a negative value during this phase, , for , will be set to this negative value and = -1 will be returned.
During the adaptive solve phase:
Function values are required to improve the estimates of the definite integrals.
If , any evaluation of will be discarded, so there is no need to provide them.
If , must be provided in .
If , or , the current error estimate of integral does not require integrand to be evaluated and provided in .
Should you choose to, integrand can be evaluated in which case must be set to .
and contain complete information during this phase.
If is set to a negative value during this phase = 1, 2 or 3 will be returned and the elements of will reflect the current state of the adaptive process.
On final exit: .
Indicates the algorithm has completed.
- sidint
For advanced users.
On intermediate exit: identifies a specific set of abscissae, , returned during the integration process. When a new set of abscissae are generated the value of is incremented by . Advanced users may store calculations required for an identified set , and reuse them should
dim1_gen_vec_multi_rcomm
return the same value of , i.e., the same set of abscissae was used.- nxint
On intermediate exit: , the number of abscissae at which integrands are required.
- Other Parameters
- ‘Absolute Interval Minimum’float
Default
, the absolute lower limit for a segment to be considered for subdivision. See also ‘Relative Interval Minimum’ and Further Comments.
Constraint: .
- ‘Absolute Tolerance’float
Default
, the absolute tolerance required. See also ‘Relative Tolerance’ and Notes.
Constraint: .
- ‘Extrapolation’str
Default
Activate or deactivate the use of the algorithm (Wynn (1956)). ‘Extrapolation’ often reduces the number of iterations required to achieve the desired solution, but it can occasionally lead to premature convergence towards an incorrect answer.
Use extrapolation.
Disable extrapolation.
- ‘Extrapolation Safeguard’float
Default
. If is the estimated error from the quadrature evaluation alone, and is the error estimate determined using extrapolation, then the extrapolated solution will only be accepted if .
- ‘Maximum Subdivisions’int
Default
, the maximum number of subdivisions the algorithm may use in the adaptive phase, forming at most an additional segments.
- ‘Primary Divisions’int
Default
, the number of initial segments of the domain . By default the initial segment is the entire domain.
Constraint: .
- ‘Primary Division Mode’str
Default
Determines how the initial set of segments will be generated.
- AUTOMATIC
dim1_gen_vec_multi_rcomm
will automatically generate segments of equal size covering the interval .- MANUAL
dim1_gen_vec_multi_rcomm
will use the break-points , for , supplied in on initial entry to generate the initial segments covering . These may be supplied in any order, however it will be more efficient to supply them in ascending (or descending if ) order. Repeated break-points are allowed, although this will generate fewer initial segments.
Note: an absolute bound on the size of an initial segment of is automatically applied in all cases, and will result in fewer initial subdivisions being generated if automatically generated or supplied break-points result in segments smaller than this.
- ‘Prioritize Error’str
Default
Indicates how new subdivisions of segments sustaining unacceptable local errors for integrals should be prioritized.
Segments with lower level with unsatisfactory error estimates will be chosen over segments with greater error on higher levels. This will probably lead to more integrals being improved in earlier iterations of the algorithm, and hence will probably lead to fewer repeated returns (see argument ), and to more integrals being satisfactorily estimated if computational exhaustion occurs.
The segment with the worst overall error will be split, regardless of level. This will more rapidly improve the worst integral estimates, although it will probably result in the fewest integrals being improved in earlier iterations, and may hence lead to more repeated returns (see argument ), and potentially fewer integrals satisfying the requested tolerances if computational exhaustion occurs.
- ‘Quadrature Rule’str
Default
The basic quadrature rule to be used during the integration. Currently Gauss–Kronrod rules are available, all identifiable by the letters GK followed by the number of points required by the Kronrod rule. Higher order rules generally provide higher accuracy with fewer subdivisons. However, for integrands with sharp singularities, lower order rules may be more efficient, particularly if the integrand away from the singularity is well behaved. With higher order rules, you may need to increase the ‘Absolute Interval Minimum’ and the ‘Relative Interval Minimum’ to maintain numerical difference between the abscissae and the segment bounds.
- GK15
The Gauss–Kronrod rule based on Gauss points and Kronrod points.
- GK21
The Gauss–Kronrod rule based on Gauss points and Kronrod points. This is the rule used by
dim1_fin_general()
.- GK31
The Gauss–Kronrod rule based on Gauss points and Kronrod points.
- GK41
The Gauss–Kronrod rule based on Gauss points and Kronrod points.
- GK51
The Gauss–Kronrod rule based on Gauss points and Kronrod points.
- GK61
The Gauss–Kronrod rule based on Gauss points and Kronrod points. This is the highest order rule, most suitable for highly oscilliatory integrals.
- ‘Relative Interval Minimum’float
Default
, the relative factor in the lower limit, , for a segment to be considered for subdivision. See also ‘Absolute Interval Minimum’ and Further Comments.
Constraint: .
- ‘Relative Tolerance’float
Default
, the required relative tolerance. See also ‘Absolute Tolerance’ and Notes.
Constraint: .
Note: setting both is possible, although it will most likely result in an excessive amount of computational effort.
- ‘Index LDI’int
query only
, the index of [‘icom’] required for obtaining . See Details of the Computation.
- ‘Index LDR’int
query only
, the index of [‘icom’] required for obtaining . See Details of the Computation.
- ‘Index NSDIV’int
query only
, the index of [‘icom’] required for obtaining . See Details of the Computation.
- ‘Index NSEG’int
query only
, the index of [‘icom’] required for obtaining . See Details of the Computation.
- ‘Index FCP’int
query only
, the index of [‘icom’] required for obtaining . See Details of the Computation.
- ‘Index EVALSP’int
query only
, the index of [‘icom’] required for obtaining . See Details of the Computation.
- ‘Index DSP’int
query only
, the index of [‘icom’] required for obtaining . See Details of the Computation.
- ‘Index ESP’int
query only
, the index of [‘icom’] required for obtaining . See Details of the Computation.
- ‘Index SINFOIP’int
query only
, the index of [‘icom’] required for obtaining . See Details of the Computation.
- ‘Index SINFORP’int
query only
, the index of [‘icom’] required for obtaining . See Details of the Computation.
- Raises
- NagValueError
- (errno )
had an illegal value.
On entry, .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, and at least one supplied break-point in is outside of the domain of integration.
- (errno )
is insufficient for the chosen options.
On entry, .
Constraint: .
- (errno )
Either the option arrays [‘iopts’] and [‘opts’] have not been initialized for
dim1_gen_vec_multi_rcomm
, or they have become corrupted.- (errno )
On entry, one of [‘icom’] and [‘com’] has become corrupted.
- Warns
- NagAlgorithmicWarning
- (errno )
Evaluation of all integrals has been stopped during the initial phase.
- (errno )
At least one error estimate exceeded the requested tolerances.
- (errno )
Extremely bad behaviour was detected for at least one integral.
- (errno )
Extremely bad behaviour was detected for at least one integral. At least one other integral error estimate was above the requested tolerance.
- Notes
dim1_gen_vec_multi_rcomm
is an extension to various QUADPACK routines, including QAG, QAGS and QAGP. The extensions made allow multiple integrands to be evaluated simultaneously, using a vectorized interface and reverse communication.The quadrature scheme employed by
dim1_gen_vec_multi_rcomm
can be chosen by you. Six Gauss–Kronrod schemes are available. The algorithm incorporates a global acceptance criterion (as defined by Malcolm and Simpson (1976)), optionally together with the ε-algorithm (see Wynn (1956)) to perform extrapolation. The local error estimation is described in Piessens et al. (1983).dim1_gen_vec_multi_rcomm
is the integration function in the suite of functionsdim1_gen_vec_multi_rcomm
anddim1_gen_vec_multi_dimreq()
. It also uses options, which can be set and queried using the functionsopt_set()
andopt_get()
respectively. The options available are described in Other Parameters.The algorithm used by
dim1_gen_vec_multi_rcomm
is divided into an initial solve phase and an adaptive solve phase.During the initial solve phase, the first estimation of the definite integral and error estimate is constructed over the interval . This will have been divided into level segments, where is the number of ‘Primary Divisions’, and will use any provided break-points if .
Once a complete integral estimate over is available, i.e., after all the estimates for the level segments have been evaluated, the function enters the adaptive phase. The estimated errors are tested against the requested tolerances and , corresponding to the ‘Absolute Tolerance’ and ‘Relative Tolerance’ respectively. Should this test fail, and additional subdivision be allowed, a segment is selected for subdivision, and is subsequently replaced by two new segments at the next level of refinement. How this segment is chosen may be altered by setting ‘Prioritize Error’ to either favour the segment with the maximum error, or the segment with the lowest level supporting an unacceptable (although potentially non-maximal) error. Up to subdivisions are allowed if sufficient memory is provided, where is the value of ‘Maximum Subdivisions’.
Once a sufficient number of error estimates have been constructed for a particular integral, the function may optionally use ‘Extrapolation’ to attempt to accelerate convergence. This may significantly lower the amount of work required for a given integration. To minimize the risk of premature convergence from extrapolation, a safeguard can be set using ‘Extrapolation Safeguard’, and the extrapolated solution will only be considered if , where and are the estimated error directly from the quadrature and from the extrapolation respectively. If extrapolation is successful for the computation of integral , the extrapolated solution will be returned in on completion of
dim1_gen_vec_multi_rcomm
. Otherwise the direct solution will be returned in . This is indicated by the value of on completion.
- References
Malcolm, M A and Simpson, R B, 1976, Local versus global strategies for adaptive quadrature, ACM Trans. Math. Software (1), 129–146
Piessens, R, 1973, An algorithm for automatic integration, Angew. Inf. (15), 399–401
Piessens, R, de Doncker–Kapenga, E, Überhuber, C and Kahaner, D, 1983, QUADPACK, A Subroutine Package for Automatic Integration, Springer–Verlag
Wynn, P, 1956, On a device for computing the transformation, Math. Tables Aids Comput. (10), 91–96