IMSL_INTFCN:
Functions Based on Gauss-Kronrod Rules
Syntax | Return Value | Arguments | Keywords | Discussion | Example | Errors
This version of the IMSL_INTFCN function integrates functions using a globally adaptive scheme based on Gauss-Kronrod rules.
Note
The RULE keyword must be supplied to use this integration method.
Syntax
Result = IMSL_INTFCN(f, a, b, RULE = {1-6} [, RULE=value] )
Return Value
The value of:
is returned. If no value can be computed, the floating-point value NaN (Not a Number) is returned.
Arguments
f
A scalar string specifying the name of a user-supplied function to be integrated. The function f accepts one scalar parameter and returns a single scalar of the same type.
a
A scalar expression specifying the lower limit of integration.
b
A scalar expression specifying the upper limit of integration.
Keywords
In addition to the global IMSL_INTFCN keywords listed in the main section under Keywords, the following keywords are available:
RULE
Set this keyword equal to an integer representing the Gauss-Kronrod rule to use. Possible values are:
|
Rule
|
Gauss-Kronrod Rule
|
|---|---|
|
|
7-15 points |
|
|
10-21 points |
|
|
15-31 points |
|
|
20-41 points |
|
|
25-51 points |
|
|
30-61 points |
Discussion
This method is a general-purpose integrator that uses a globally adaptive scheme to reduce the absolute error. It subdivides the interval [a, b] and uses a (2k+1)-point Gauss-Kronrod rule to estimate the integral over each subinterval. The error for each subinterval is estimated by comparison with the k-point Gauss quadrature rule. The subinterval with the largest estimated error is then bisected, and the same procedure is applied to both halves. The bisection process is continued until either the error criterion is satisfied, roundoff error is detected, the subintervals become too small, or the maximum number of subintervals allowed is reached. This method is based on the subroutine QAG by Piessens et al. (1983).
If this method is used, the function should be coded to protect endpoint singularities if they exist.
Example
The value of:

is computed. Since the integrand is oscillatory, RULE = 6 is used. The exact value is 0.50406706. The values of the actual and estimated error are machine dependent.
.RUN ; Define the function to be integrated. FUNCTION f, x RETURN, SIN(1/x) END ans = IMSL_INTFCN('f', 0, 1, RULE=6) ; Call IMSL_INTFCN, to compute the integral based on the ; specified Gauss-Kronrod rule. PM, 'Computed Answer:',ans ; Output the results. Computed Answer: 0.504051 exact = .50406706 PM, 'EXACT - COMPUTED:', exact - ans Exact - Computed: 1.62125e-05
Errors
See Errors.