XLPack 7.0
XLPack Numerical Library (C API) Reference Manual
Loading...
Searching...
No Matches

◆ qagi()

void qagi ( double(*)(double)  f,
double  bound,
int  inf,
double  epsabs,
double  epsrel,
int  limit,
double *  result,
double *  abserr,
int *  neval,
int *  last,
double  work[],
int  lwork,
int  iwork[],
int *  info 
)

Semi-infinite/infinite interval adaptive quadrature (15-point Gauss-Kronrod rule)

Purpose
This routine computes I = integral of f(x) over [bound, +inf], [-inf, bound] or [-inf, +inf], satisfying the requested accuracy, where f(x) is a given function defined by a user supplied subroutine.

15-point Gauss-Kronrod rule is used, and the integration interval will be adaptively subdivided to satisfy the requested accuracy.
The semi-infinite integration range is mapped onto the interval [0, 1], and then the integration rule is applied to compute the required integral.
∫ f(x)dx [bound, +∞] = ∫ f(bound + (1 - t)/t) / t^2 dt [0, 1]
The infinite integral will be computed as the sum of two semi-infinite integrals.
∫ f(x)dx [-∞, +∞] = ∫ (f(x) + f(-x)) dx [0, +∞]
Parameters
[in]fThe user supplied subroutine which calculates the integrand function f(x) defined as follows.
double f(double x)
{
return computed f(x) value
}
[in]boundThe finite bound of original integration range. (Not referenced if interval is doubly infinite (inf = 2))
[in]infThe kind of integration range.
= 1: Semi-infinite integral [bound, +∞]
= -1: Semi-infinite integral [-∞, bound]
= 2: Infinite integral [-∞, +∞]
(If other value is specified, inf = 2 is assumed)
[in]epsabsAbsolute accuracy requested.
The requested accuracy is assumed to be satisfied if abserr <= max(epsabs, epsrel*|result|)).
[in]epsrelRelative accuracy requested.
The requested accuracy is assumed to be satisfied if abserr <= max(epsabs, epsrel*|result|)).
If epsabs <= 0 and epsrel < 50*eps, epsrel is assumed to be 50*eps, where eps is the machine precision.
[in]limitMaximum number of subintervals in the partition of the given integration interval. (limit >= 1)
[out]resultApproximation to the integral.
[out]abserrEstimate of the modulus of the absolute error, which should equal or exceed the true error.
[out]nevalNumber of integrand evaluations.
[out]lastNumber of subintervals produced in the subdivision process.
[out]work[]Array work[lwork]
Work array.
work[0], ..., work[last-1]: Left end points of the subintervals
work[limit], ..., work[limit+last-1]: Right end poits of the subintervals.
work[2*limit], ..., work[2*limit+last-1]: The integral approximations over the subintervals.
work[3*limit], ..., work[3*limit+last-1]: The error estimates over the subintervals.
[in]lworkThe length of work[]. (lwork >= 4*limit)
[out]iwork[]Array iwork[liwork] (liwork >= limit)
Work array.
The first k elements contain pointers to the error estimates over the subintervals, such that work[3*limit+iwork[0]-1], ..., work[3*limit+iwork[k-1]-1] form a decreasing sequence with k = last if last <= limit/2+2, and k = limit+1-last otherwise.
[out]info= 0: Successful exit
= -6: The argument limit had an illegal value (limit < 1)
= -12: The argument lwork had an illegal value (lwork < 4*limit)
= 1: Maximum number of subdivisions allowed has been achieved
= 2: The occurrence of roundoff error is detected, which prevents the requested tolerance from being achieved
= 3: Extremely bad integrand behavior occurs at some points of the integration interval
= 4: The algorithm does not converge. It is presumed that the requested tolerance cannot be achieved, and that the returned result is the best which can be obtained
= 5: The integral is probably divergent, or slowly convergent
Reference
SLATEC (QUADPACK)