|
|
◆ Qagi_r()
| Sub Qagi_r |
( |
Bound As |
Double, |
|
|
Inf As |
Long, |
|
|
Result As |
Double, |
|
|
Info As |
Long, |
|
|
XX As |
Double, |
|
|
YY As |
Double, |
|
|
IRev As |
Long, |
|
|
Optional AbsErr As |
Double, |
|
|
Optional Neval As |
Long, |
|
|
Optional EpsAbs As |
Double = -1, |
|
|
Optional EpsRel As |
Double = -1, |
|
|
Optional Limit As |
Long = -1, |
|
|
Optional Last As |
Long |
|
) |
| |
Infinite interval automatic quadrature (adaptive automatic quadrature) (reverse communication version)
- Purpose
- This routine computes I = integral of f(x) over [Bound, +inf], [-inf, Bound] or [-inf, +inf], satisfying the requested accuracy. The integrand function f(x) is computed and provided by the user in accordance with IRev.
15-point Gauss-Kronrod rule is used, and the integration interval will be adaptively subdivided to satisfy the requested accuracy.
The semi-infinite integration range is mapped onto the interval [0, 1], and then the integration rule is applied to compute the required integral. ∫ f(x)dx [Bound, +∞] = ∫ f(Bound + (1 - t)/t) / t^2 dt [0, 1]
The infinite integral will be computed as the sum of two semi-infinite integrals. ∫ f(x)dx [-∞, +∞] = ∫ (f(x) + f(-x)) dx [0, +∞]
- Parameters
-
| [in] | Bound | The finite bound of original integration range. (Not referenced if interval is doubly infinite (Inf = 2)) |
| [in] | Inf | The kind of integration range.
= 1: Semi-infinite integral [Bound, +∞]
= -1: Semi-infinite integral [-∞, Bound]
= 2: Infinite integral [-∞, +∞]
(If other value is specified, Inf = 2 is assumed) |
| [out] | Result | Approximation to the integral. |
| [out] | Info | = 0: Successful exit. = -7: The argument IRev had an illegal value.
= 1: Maximum number of subdivisions allowed has been achieved.
= 2: The occurrence of roundoff error is detected, which prevents the requested tolerance from being achieved.
= 3: Extremely bad integrand behavior occurs at some points of the integration interval.
= 4: The algorithm does not converge. It is presumed that the requested tolerance cannot be achieved, and that the returned result is the best which can be obtained.
= 5: The integral is probably divergent, or slowly convergent. |
| [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. |
| [out] | Neval | (Optional)
Number of integrand evaluations. |
| [in] | EpsAbs | (Optional)
Absolute accuracy requested. (default = 0)
The requested accuracy is assumed to be satisfied if AbsErr <= max(EpsAbs, EpsRel*|Result|))
(If EpsAbs < 0, the default value will be used) |
| [in] | EpsRel | (Optional)
Relative accuracy requested. (default = 1.0e-12)
The requested accuracy is assumed to be satisfied if AbsErr <= max(EpsAbs, EpsRel*|Result|))
If EpsAbs <= 0 and EpsRel < 50*eps, EpsRel is assumed to be 50*eps, where eps is the machine precision.
(If EpsRel < 0, the default value will be used) |
| [in] | Limit | (Optional)
Maximum number of subintervals in the partition of the given integration interval (limit >= 1) (default = 100)
(If Limit < 1, the default value will be used) |
| [out] | Last | (Optional)
Number of subintervals produced in the subdivision process. |
- Reference
- SLATEC (QUADPACK)
- Example Program
- Compute the following integral.
∫ 1/(1 + x^2) dx [0, +∞] (= π/2)
Sub Ex_Qagi_r()
Dim Bound As Double, Inf As Long, Result As Double, Info As Long
Dim XX As Double, YY As Double, IRev As Long
Bound = 0: Inf = 1
IRev = 0
Do
Call Qagi_r(Bound, Inf, 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
- Example Results
S = 1.5707963267949 S(true) = 1.5707963267949
Info = 0
|