XLPack 7.0
XLPack Numerical Library (Excel VBA) Reference Manual
Loading...
Searching...
No Matches

◆ Dehint_r()

Sub Dehint_r ( A As  Double,
Result As  Double,
Info As  Long,
XX As  Double,
YY As  Double,
IRev As  Long,
Optional Neval As  Long,
Optional L As  Long,
Optional Eps As  Double = -1 
)

Semi-infinite interval automatic quadrature (double exponential (DE) formula) (reverse communication version)

Purpose
This routine computes the integral of f(x) over [a, +∞], satisfying the requested accuracy. The integrand f(x) is computed and provided by the user in accordance with IRev.
The result is obtained by the automatic integration applying the double exponential (DE) formula.

The double exponential (DE) formulas (see Defin) for semi-infinite interval [0, +∞] is obtained by using the following transformation functions.
(1) φ(t) = exp(t/2 - exp(-t))
(2) φ(t) = exp(t - exp(-t))
(3) φ(t) = exp(2sinh(t))
(1) is suitable for the functions decaying very rapidly such as f(x) = f1(x)exp(-x^2). (2) is suitable for the functions with an exponential factor such as f(x) = f2(x)exp(-x). (3) is used for the slowly decaying rational or algebraic functions.
This routine will automatically choose one of the above three functions by examining the behavior of the integrand. The argument L returns which transformation function was used.
Parameters
[in]ALower limit of integration a.
[out]ResultApproximation to the integral.
[out]Info= 0: Successful exit.
= -6: The argument IRev had an illegal value.
= 1: Slow decay on negative side.
= 2: Slow decay on positive side.
= 3: Both of above.
= 4: Insufficient mesh refinement. (Eps too small, singularity within integral interval, etc.)
[out]XXWhen returned with IRev = 1, XX contains the abscissa where the function value should be evaluated and given in the next call.
[in]YYWhen returned with IRev = 1, the function value f(XX) should be given in YY in the next call.
[in,out]IRevControl variable for reverse communication.
[in] Before first call, IRev should be initialized to zero. On succeeding calls, IRev should not be altered.
[out] If IRev is not zero, complete the following tasks and call this routine again without changing IRev.
= 0: Computation finished. See return code in Info.
= 1: User should set the function values at XX in YY. Do not alter any variables other than YY.
[out]Neval(Optional)
Number of integrand evaluations.
[out]L(Optional)
The used transformation function.
= 0: φ(t) = exp(t/2 - exp(-t))
= 1: φ(t) = exp(t - exp(-t))
= 2: φ(t) = exp(2sinh(t))
[in]Eps(Optional)
Absolute accuracy requested. (default = 1.0e-14)
(If Eps <= 0, the default value will be used)
Reference
(Japanese book) Masatake Mori "FORTRAN77 Numerical Calculation Programming (augmented edition)" Iwanami Shoten (1987)
Example Program
Compute the following integral.
∫ 1/(1 + x^2) dx [0, +∞] (= π/2)
Sub Ex_Dehint_r()
Dim A As Double, Result As Double, Info As Long
Dim XX As Double, YY As Double, IRev As Long
A = 0
IRev = 0
Do
Call Dehint_r(A, Result, Info, XX, YY, IRev)
If IRev = 1 Then YY = 1 / (1 + XX ^ 2)
Loop While IRev <> 0
Debug.Print "S =", Result, "S(true) =", Dconst(13) / 2
Debug.Print "Info =", Info
End Sub
Function Dconst(I As Long, Optional Info As Long) As Double
Numerical quantities
Sub Dehint_r(A As Double, Result As Double, Info As Long, XX As Double, YY As Double, IRev As Long, Optional Neval As Long, Optional L As Long, Optional Eps As Double=-1)
Semi-infinite interval automatic quadrature (double exponential (DE) formula) (reverse communication ...
Example Results
S = 1.5707963267949 S(true) = 1.5707963267949
Info = 0