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

◆ Qk31()

Sub Qk31 ( F As  LongPtr,
A As  Double,
B As  Double,
Result As  Double,
Optional AbsErr As  Double,
Optional ResAbs As  Double,
Optional ResAsc As  Double 
)

Finite interval quadrature (31 point Gauss Kronrod formula)

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 defined by a user supplied subroutine.
The integral will be evaluated with a 31 point Gauss Kronrod formula.
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.
[out]ResultApproximation to I = integral of f over [a, b].
[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))
Function F1(X As Double) As Double
F1 = 1 / (1 + X ^ 2)
End Function
Sub Ex_Qk31()
Dim A As Double, B As Double, Result As Double
A = 0: B = 4
Call Qk31(AddressOf F1, A, B, Result)
Debug.Print "S =", Result, "S(true) =", Atn(4)
End Sub
Sub Qk31(F As LongPtr, A As Double, B As Double, Result As Double, Optional AbsErr As Double, Optional ResAbs As Double, Optional ResAsc As Double)
Finite interval quadrature (31 point Gauss Kronrod formula)
Example Results
S = 1.32581766366803 S(true) = 1.32581766366803