|
|
◆ Qawf()
| Sub Qawf |
( |
F As |
LongPtr, |
|
|
A As |
Double, |
|
|
Omega 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 Limlst As |
Long = -1, |
|
|
Optional Lst As |
Long, |
|
|
Optional Limit As |
Long = -1, |
|
|
Optional Maxp1 As |
Long = -1 |
|
) |
| |
Semi-infinite interval adaptive quadrature for Fourier integrals (25-point Clenshaw-Curtis and 15-point Gauss-Kronrod rule)
- Purpose
- The routine calculates an approximation result to a Fourier integral I = ∫ f(x)*w(x) dx over [a, +∞] satisfying the requested accuracy, where the weight function w(x) = cos(ω*x) or sin(ω*x).
The integration interval is divided into subintervals, and the integral of successive subintervals are computed by Qawo until the requested accuracy is satisfied and accumulated. The 25-point modified Clenshaw-Curtis rule and a 15-point Gauss-Kronrod rule are used.
- Parameters
-
| [in] | F | The 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] | A | Lower limit of integration a. |
| [in] | Omega | Parameter ω in the weight function. |
| [in] | Integr | Indicates which weight function is to be used.
= 1: w(x) = cos(ω*x)
= 2: w(x) = sin(ω*x) |
| [out] | Result | Approximation to the integral. |
| [out] | Info | = 0: Successful exit.
= -4: The argument Integr had an illegal value. (Integr <> 1 and Integr <> 2)
= 1: Maximum number of subintervals Ck allowed has been achieved.
= 4: Extrapolation table constructed for convergence acceleration does not converge to within the requested accuracy.
= 7: Bad integrand behavior occurs within one or more of the subintervals. |
| [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. (EpsAbs > 0) (default = 1.0e-12)
(If EpsAbs <= 0, the default value will be used) |
| [in] | Limlst | (Optional)
Maximum number of subintervals. (Limlst >= 3) (default = 50)
(If Limlst < 3, the default value will be used) |
| [out] | Lst | (Optional)
Number of subintervals actually needed for the integration. |
| [in] | Limit | (Optional)
Maximum number of subintervals to be produced by Qawo to integrate each subinterval. (Limit >= 1) (default = 100)
(If Limit < 1, the default value will be used) |
| [in] | Maxp1 | (Optional)
Upper bound on the number of Chebyshev moments which can be stored (Maxp1 >= 1) (default = 21)
(If Maxp1 < 1, the default value will be used) |
- Reference
- SLATEC (QUADPACK)
- Example Program
- Compute the following integral.
∫ exp(-x^2)cos(x) dx [0, +∞] (= exp(-1/4)*1/2*√π)
Function F6(X As Double) As Double
F6 = Exp(-X ^ 2)
End Function
Sub Ex_Qawf()
Dim A As Double, Omega As Double, Integr As Long, Result As Double
Dim Info As Long
A = 0
Omega = 1
Integr = 1
Call Qawf(AddressOf F6, A, Omega, Integr, Result, Info)
Debug.Print "S =", Result, "S(true) =", Exp(-1 / 4) * Dconst(17) / 2
Debug.Print "Info =", Info
End Sub
- Example Results
S = 0.690194223521571 S(true) = 0.690194223521572
Info = 0
|