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

◆ Qk21_r()

Sub Qk21_r ( A As  Double,
B As  Double,
Result As  Double,
XX As  Double,
YY As  Double,
IRev As  Long,
Optional AbsErr As  Double,
Optional ResAbs As  Double,
Optional ResAsc As  Double 
)

Finite interval quadrature (21 point Gauss-Kronrod rule) (reverse communication version)

Purpose
This routine routine computes
  I = integral of f over [a, b] with error estimate, and
  J = integral of abs(f) over [a, b],
where f is a given function. User should provide the necessary computed values of f according to the argument IRev.
The integral will be evaluated with the 21 point Gauss-Kronrod rule.
Parameters
[in]ALower limit of integration a.
[in]BUpper limit of integration b.
[out]ResultApproximation to I = integral of f over [a, b].
[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 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]AbsErr(Optional)
Estimate of the modulus of the absolute error, which should equal or exceed the true error.
[out]ResAbs(Optional)
Approximation to J = integral of abs(f) over [a, b].
[out]ResAsc(Optional)
Approximation to the integral of abs(f - I/(b - a)) over [a, b].
Reference
SLATEC (QUADPACK)
Example Program
Compute the following integral.
∫ 1/(1 + x^2) dx [0, 4] (= atan(4))
Sub Ex_Qk21_r()
Dim A As Double, B As Double, Result As Double
Dim XX As Double, YY As Double, IRev As Long
A = 0: B = 4
IRev = 0
Do
Call Qk21_r(A, B, Result, XX, YY, IRev)
If IRev = 1 Then YY = 1 / (1 + XX ^ 2)
Loop While IRev <> 0
Debug.Print "S =", Result, "S(true) =", Atn(4)
End Sub
Sub Qk21_r(A As Double, B As Double, Result As Double, XX As Double, YY As Double, IRev As Long, Optional AbsErr As Double, Optional ResAbs As Double, Optional ResAsc As Double)
Finite interval quadrature (21 point Gauss-Kronrod rule) (reverse communication version)
Example Results
S = 1.3258176636671 S(true) = 1.32581766366803