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

◆ Qk15i()

Sub Qk15i ( F As  LongPtr,
A As  Double,
Inf As  Long,
Result As  Double,
Optional AbsErr As  Double 
)

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

Purpose
The routine computes an approximation to the integral of function f(x) over a semi-infinite or infinite interval with the 15 point Gauss-Kronrod rule. The integrand f(x) is defined by the user supplied subroutine.

The function f(x) is transformed to the function f01(t) so that the semi-infinite integration is obtained by computing the finite integration over [0, 1].
∫ f(x)dx [a, +∞] = ∫ f01(t)dt [0, 1] where f01(t) = f(a + (1 - t)/t)/t^2
The infinite integral is 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.
Function F(X As Double) As Double
F = f(X)
End Function
X should not be changed.
[in]ALower or upper bound of semi-infinite integration interval a. (Not referenced if infinite interval (Inf = 2))
[in]InfThe kind of integration range.
= 1: Semi-infinite integral [a, +∞]
= -1: Semi-infinite integral [-∞, a]
= 2: Infinite integral [-∞, +∞]
(If other value is specified, Inf = 2 is assumed)
[out]ResultApproximation to the integral.
[out]AbsErr(Optional)
Estimate of the modulus of the absolute error, which should equal or exceed the true error.
Reference
SLATEC (QUADPACK)
Example Program
Compute the following integral.
∫ 1/(1 + x^2) dx [0, +∞] (= π/2)
Function F1(X As Double) As Double
F1 = 1 / (1 + X ^ 2)
End Function
Sub Ex_Qk15i()
Dim A As Double, Inf As Long, Result As Double
A = 0
Inf = 1
Call Qk15i(AddressOf F1, A, Inf, Result)
Debug.Print "S =", Result, "S(true) =", Dconst(13) / 2
End Sub
Function Dconst(I As Long, Optional Info As Long) As Double
Numerical quantities
Sub Qk15i(F As LongPtr, A As Double, Inf As Long, Result As Double, Optional AbsErr As Double)
Semi-infinite/infinite interval quadrature (15-point Gauss-Kronrod rule)
Example Results
S = 1.57079632684678 S(true) = 1.5707963267949