|
|
◆ Deiint()
| Sub Deiint |
( |
F As |
LongPtr, |
|
|
Result As |
Double, |
|
|
Info As |
Long, |
|
|
Optional Neval As |
Long, |
|
|
Optional Eps As |
Double = -1 |
|
) |
| |
Infinite interval automatic quadrature (double exponential (DE) formula)
- Purpose
- This routine computes the integral of f(x) over [-∞, +∞], satisfying the requested accuracy, where f(x) is a given function defined by a user supplied subroutine f.
The result is obtained by the automatic integration applying the double exponential (DE) formula.
The double exponential (DE) formulas (see Defin) for infinite interval [-∞, +∞] is obtained by using the following transformation function. φ(t) = sinh((π/2)sinh(t))
This formula is suitable for the slowly decaying functions.
- Parameters
-
| [in] | F | The user supplied subroutine which calculates the integrand function f(x) defined as follows. Function F(X As Double) As Double
F = f(X)
End Function
X should not be changed. |
| [out] | Result | Approximation to the integral. |
| [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. (Eps too small, singularity within integral interval, etc.) |
| [out] | Neval | (Optional)
Number of integrand evaluations. |
| [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 [-∞, +∞] (= π)
Function F1(X As Double) As Double
F1 = 1 / (1 + X ^ 2)
End Function
Sub Ex_Deiint()
Dim Result As Double, Info As Long
Call Deiint(AddressOf F1, Result, Info)
Debug.Print "S =", Result, "S(true) =", Dconst(13)
Debug.Print "Info =", Info
End Sub
Function Dconst(I As Long, Optional Info As Long) As Double Numerical quantities
Sub Deiint(F As LongPtr, Result As Double, Info As Long, Optional Neval As Long, Optional Eps As Double=-1) Infinite interval automatic quadrature (double exponential (DE) formula)
- Example Results
S = 3.14159265358979 S(true) = 3.14159265358979
Info = 0
|