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

◆ defint()

void defint ( double(*)(double)  f,
double  a,
double  b,
double  eps,
int  l,
double *  result,
int *  neval,
int *  info 
)

Finite interval automatic quadrature (double exponential (DE) formula)

Purpose
This routine computes the integral of f(x) over [a, b], satisfying the requested accuracy, where f(x) is a given function defined by the user supplied function f.
The result is obtained by the automatic integration applying the double exponential (DE) formula.

The integral interval [-1, 1] can be transformed into the infinite interval [-∞, ∞] by the variable transformation.
∫ f(x)dx [-1, 1] = ∫ g(t)dt [-∞, ∞]
where x=φ(t), g(t) = f(φ(t))φ'(t)
φ(t) is the monotone function, and it satisfies φ(-∞) = -1, φ(∞) = 1.
By choosing suitable φ(t), g(t) can have the double exponential asymptotic behavior and can be integrated efficiently by trapezoidal rule. The following transformation function is used in this routine.
φ(t) = tanh((π/2)sinh(t))
The DE formula can be applied even if the singularities exist at the end points.
Parameters
[in]fThe user supplied function which computes the integrand function f(x) normally (when l = 0) defined as follows.
double f(double x)
{
return computed f(x) value;
}
When f(x) has singularities at endpoints, f may define the function f2(y) instead of f(x) and defint may be called with l = 1 so that the integral of f(x) on [a, b] can be obtained with better precision, where f2(y) is defined as follows.
  f2(y) = f(a - y) (-(b - a)/2 < y < 0)
  f2(y) = f(b - y) (0 < y <= (b - a)/2)
[in]aLower limit of integration.
[in]bUpper limit of integration.
[in]epsAbsolute accuracy requested.
max(|eps|, 1.0e-32) is used as the tolerance.
[in]l= 0: The user supplied subroutine f computes f(x).
= 1: The user supplied subroutine f computes f2(y).
(For other values, l = 0 is assumed)
[out]resultApproximation to integral of f(x) over [a, b].
[out]nevalNumber of integrand evaluations.
[out]info= 0: Successful exit
= 1: Slow decay on negative side
= 2: Slow decay on positive side
= 3: Both of above
= 4: Insufficient mesh refinement
Reference
Masatake Mori "FORTRAN77 Numerical Calculation Programming (augmented edition)" Iwanami Shoten, 1987. (Japanese book)