|
|
◆ Qk15i_r()
| Sub Qk15i_r |
( |
A As |
Double, |
|
|
Inf As |
Long, |
|
|
Result As |
Double, |
|
|
XX As |
Double, |
|
|
YY As |
Double, |
|
|
IRev As |
Long, |
|
|
Optional AbsErr As |
Double |
|
) |
| |
Semi-infinite/infinite interval quadrature (15-point Gauss-Kronrod rule) (reverse communication version)
- 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 computed and provided by the user in accordance with IRev.
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] | A | Lower or upper bound of semi-infinite integration interval a. (Not referenced if infinite interval (Inf = 2)) |
| [in] | Inf | The 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] | Result | Approximation to the integral. |
| [out] | XX | When returned with IRev = 1, XX contains the abscissa where the function value should be evaluated and given in the next call. |
| [in] | YY | When returned with IRev = 1, the function value f(XX) should be given in YY in the next call. |
| [in,out] | IRev | Control 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] | 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)
Sub Ex_Qk15i_r()
Dim A As Double, Inf As Long, Result As Double
Dim XX As Double, YY As Double, IRev As Long
A = 0
Inf = 1
IRev = 0
Do
Call Qk15i_r(A, Inf, Result, 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
End Sub
Function Dconst(I As Long, Optional Info As Long) As Double Numerical quantities
Sub Qk15i_r(A As Double, Inf As Long, Result As Double, XX As Double, YY As Double, IRev As Long, Optional AbsErr As Double) Semi-infinite/infinite interval quadrature (15-point Gauss-Kronrod rule) (reverse communication versi...
- Example Results
S = 1.57079632684678 S(true) = 1.5707963267949
|