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

◆ Qaws()

Sub Qaws ( F As  LongPtr,
A As  Double,
B As  Double,
Alpha As  Double,
Beta As  Double,
Integr As  Long,
Result As  Double,
Info 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 
)

Finite interval adaptive quadrature for singular functions (25-point Clenshaw-Curtis and 15-point Gauss-Kronrod rule)

Purpose
The routine calculates an approximation result to a definite integral I = integral of f(x)*w(x) over [a, b] satisfying the requested accuracy, where the weight function w(x) has algebraic-logarithmic singularities at the end points of an integration region. See parameter Integr.
Result is obtained by the adaptive integration applying a 25-point modified Clenshaw-Curtis rule and a 15-point Gauss-Kronrod rule to satisfy the requested accuracy.
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 limit of integration a.
[in]BUpper limit of integration b.
[in]AlphaParameter α in the weight function. (Alpha > -1)
[in]BetaParameter β in the weight function. (Beta > -1)
[in]IntegrIndicates the form of weight function w(x)
= 1: w(x) = (x - a)^α * (b - x)^β
= 2: w(x) = (x - a)^α * (b - x)^β * ln(x - a)
= 3: w(x) = (x - a)^α * (b - x)^β * ln(b - x)
= 4: w(x) = (x - a)^α * (b - x)^β * ln(x - a) * ln(b - x)
[out]ResultApproximation to the integral.
[out]Info= 0: Successful exit.
= -2: The argument A (or B) had an illegal value. (A >= B)
= -4: The argument Alpha had an illegal value. (Alpha <= -1)
= -5: The argument Beta had an illegal value. (Beta <= -1)
= -6: The argument Integr had an illegal value. (Integr < 1 or Integr > 4)
= 1: Maximum number of subdivisions allowed has been reached.
= 2: Requested tolerance cannot be achieved due to roundoff error.
= 3: Bad integrand behavior found in the integration interval.
[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 [a, b] (limit >= 2) (default = 100)
(If Limit < 2, 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.
∫ ln(x)/(1 + ln(x)^2)^2 dx [0, 1] (= 0.1892752)
Function F4(X As Double) As Double
F4 = 0
If X > 0 Then F4 = 1 / (1 + Log(X) ^ 2) ^ 2
End Function
Sub Ex_Qaws()
Dim A As Double, B As Double, Result As Double, Info As Long
Dim Alpha As Double, Beta As Double, Integr As Long
A = 0: B = 1
Alpha = 0: Beta = 0: Integr = 2
Call Qaws(AddressOf F4, A, B, Alpha, Beta, Integr, Result, Info)
Debug.Print "S =", Result
Debug.Print "Info =", Info
End Sub
Function Beta(A As Double, B As Double, Optional Info As Long) As Double
Beta function B(a, b)
Sub Qaws(F As LongPtr, A As Double, B As Double, Alpha As Double, Beta As Double, Integr As Long, Result As Double, Info 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)
Finite interval adaptive quadrature for singular functions (25-point Clenshaw-Curtis and 15-point Gau...
Example Results
S = -0.189275187882035
Info = 0