INTFCN Function
Integrates a user-supplied function.
Usage
result = INTFCN(f, a, b)
Input Parameters
f—A scalar string specifying the name of the 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.
Returned Value
result—An estimate of the desired integral. If no value can be computed, NaN (not a number) is returned.
Global Keywords
The following seven keywords can be used in any combination with each method of integration except the non-adaptive method, which is triggered by the keyword Smooth. Because of this, these global keywords are documented here only and referred to within the Method Keywords subsections of the Optional Method of Integrations section of this routine.
Double—If present and nonzero, double precision is used.
Err_Abs—The absolute accuracy desired. (Default: Err_Abs = ε1/2, where ε is the machine precision)
Err_Est—An estimate of the absolute value of the error.
Err_Rel—The relative accuracy desired. (Default: Err_Rel = ε1/2, where ε is the machine precision)
Max_Subinter—The number of subintervals allowed.
(Default: Max_Subinter = 500)
N_Evals—A named variable into which the number of evaluations of f  is stored.
N_Subinter—A named variable into which the number of subintervals generated is stored.
Discussion
In the default case, the three input parameters f, a and b are required. Additional methods of integration are also possible using INTFCN. If another method of integration is desired, a combination of these parameters, along with additional parameters and keywords must be specified. Descriptions of the additional parameters and keywords to use for specific methods of integration are discussed in the following sections.
Optional Methods of Integration
Using different combinations of keywords and parameters, one of several types of integration can be performed including:
*Integration of functions based on Gauss-Kronrod rules
*Integration of functions with singular points given
*Integration of functions with algebraic-logarithmic singularities
*Integration of functions over an infinite or semi-infinite interval
*Integration of functions containing a sine or cosine factor
*Computation of Fourier sine and cosine transforms
*Integrals in the Cauchy principle value sense
*Integration of smooth functions using a non-adaptive rule
*Computation of two-dimensional iterated integrals
By specifying different sets of parameters and/or keywords, a number of different types of integration can be performed. Internally, the method to be used is determined by examining the combination of parameters and/or keywords used in the call to INTFCN. To specify a specific method of integration, refer to the appropriate discussion.
Integration of Functions Based on Gauss-Kronrod Rules
This method integrates functions using a globally adaptive scheme based on Gauss-Kronrod rules shown in the table that follows.
Synopsis
Triggered by the use of keyword Rule.
result = INTFCN(f, a, b, Rule = rule)
Returned Value
result—The value of:
If no value can be computed, NaN is returned.
Keywords
In addition to the keywords listed for this function, the following keyword is also available:
Rule—If specified, the integral is computed using a globally adaptive scheme based on Gauss-Kronrod rules:
*1—7-15 points
*2—10-21 points
*3—15-31 points
*4—20-41 points
*5—25-51 points
*6—30-61 points
Integration of Functions with Singular Points Given
This method integrates functions with given singularity points.
Synopsis
Requires the use of keyword Sing_Pts.
result = INTFCN(f, a, b, Sing_Pts = points)
Returned Value
result—The value of:
If no value can be computed, NaN is returned.
Keywords
In addition to the keywords listed in the Global Keywords section, the following keyword is available:
Sing_Pts—If present, specifies the abscissas of the singularities. These values should be interior to the interval [a, b].
Integrating Functions with Algebraic-logarithmic Singularities
This method integrates functions with algebraic-logarithmic singularities.
Input Parameters
alpha—The strength of the singularity at a. Must be greater than –1.
beta—The strength of the singularity at b. Must be greater than –1.
Synopsis
Triggered by the use of the parameters alpha and beta and one of the following keywords, in addition to f, a, and b.
result = INTFCN(f, a, b, alpha, beta, /Algebraic)
result = INTFCN(f, a, b, alpha, beta, /Alg_Left_Log)
result = INTFCN(f, a, b, alpha, beta, /Alg_Log)
result = INTFCN(f, a, b, alpha, beta, /Alg_Right_Log)
Returned Value
result—The value of:
where w(x) is defined by one of the following keywords. If no value can be computed, NaN is returned.
Keywords
In addition to the keywords listed in the Global Keywords section, the following keywords are available. Exactly one of the following keywords must be specified:
Algebraic—If present and nonzero, uses the weight function:
This is the default weight function for this method of integration.
Alg_Left_Log—If present and nonzero, uses the weight function:
Alg_Log—If present and nonzero, uses the weight function:
Alg_Right_Log—If present and nonzero, uses the weight function:
Integration of Functions Over an Infinite or Semi-infinite Interval
This method integrates functions over an infinite or semi-infinite interval.
Input Parameters
bound—The finite limit of integration. If either of the keywords Inf_Bound or Bound_Inf are specified, this parameter is required.
Synopsis
Triggered by the presence of the function f, a bound (bound), and one of the keywords Inf_InfInf_Bound, or Bound_Inf.
result = INTFCN(f, /Inf_Inf)
result = INTFCN(f, bound, /Inf_Bound)
result = INTFCN(f, bound, /Bound_Inf)
Returned Value
result—The value of:
where a and b are appropriate integration limits. If no value can be computed, NaN is returned.
Keywords
In addition to the keywords listed in the Global Keywords section, the following keywords are available (exactly one of the following keywords must be specified):
Bound_Inf—If present and nonzero, integrates a function over the range (bound, infinity).
Inf_Bound—If present and nonzero, integrates a function over the range (infinity, bound).
Inf_Inf—If present and nonzero, integrates a function over the range (infinity, infinity).
Integration of Functions Containing a Sine or Cosine Factor
This method integrates functions containing a sine or a cosine factor.
Input Parameters
omega—The frequency of the trigonometric weighting function.
Synopsis
Triggered by the use of parameter omega and one of the keywords Sine or Cosine, in addition to f, a, and b.
result = INTFCN(f, a, b, omega, /Sine)
result = INTFCN(f, a, b, omega, /Cosine)
Returned Value
result—The value of:
where the weight function w(ωx) as defined by the following keywords, is returned. If no value can be computed, NaN is returned.
Keywords
In addition to the keywords listed in the Global Keywords section, the following keywords are available (exactly one of the following keywords must be specified):
Cosine—If present and nonzero, cos(ωx) is used for the integration weight function.
Max_Moments—A scalar expression specifying an upper bound on the number of Chebyshev moments that can be stored. Increasing (decreasing) this number may increase (decrease) execution speed and space used. (Default: Max_Moments = 21)
Sine—If present and nonzero, sin(ωx) is used for the integration weight function.
Computation of Fourier Sine or Cosine Transforms
This method computes Fourier sine or cosine transforms.
Input Parameters
omega—The frequency of the trigonometric weighting function.
Synopsis
Triggered by the use of parameter omega and one of the keywords Sine or Cosine, in addition to f and a.
result = INTFCN(f, a, omega, /Sine)
result = INTFCN(f, a, omega, /Cosine)
Returned Value
result—The value of:
where the weight function w(ωx) as defined by the following keywords, is returned. If no value can be computed, NaN is returned.
Keywords
In addition to the keywords listed in the Global Keywords section, the following keywords are available (exactly one of the keywords Sine or Cosine must be specified):
Cosine—If present and nonzero, cos(ωx) is used for the integration weight function.
Max_Moments—The number of subintervals allowed in the partition of each cycle. (Default: Max_Moments = 21)
N_Cycles—A named variable into which the number of cycles generated is stored.
Sine—If present and nonzero, sin(ωx) is used for the integration weight function.
Integrals in the Cauchy Principle Value Sense
This method computes integrals of the form:
in the Cauchy principal value sense.
Input Parameters
c—The singular point must not equal a or b.
Synopsis
Triggered by the use of parameter c and keyword Cauchy, in addition to f, a, and b.
result = INTFCN(f, a, b, c, /Cauchy)
Returned Value
result—The value of:
If no value can be computed, NaN is returned.
Keywords
In addition to the keywords listed in the Global Keywords section, the following keyword is available (requires the use of keyword Cauchy):
Cauchy—If present and nonzero, computes integrals of the form:
in the Cauchy principal value sense.
Integration of Smooth Functions Using Nonadaptive Rule
This method integrates smooth functions using a nonadaptive rule.
Synopsis
Triggered by the use of keyword Smooth, in addition to f, a, and b.
result = INTFCN(f, a, b, /Smooth)
Returned Value
result—The value of:
If no value can be computed, NaN is returned.
Keywords
Because this method is nonadaptive, there are fewer options with the algorithm. For this method, none of the keywords described in the Global Keywords section apply. A complete list of the available keywords is given as follows. This method requires the use of the keyword Smooth.
Double—If present and nonzero, uses double precision.
Err_Abs—The absolute accuracy desired. (Default: Err_Abs = ε1/2, where ε is the machine precision)
Err_Est—A named variable into which an estimate of the absolute value of the error is stored.
Err_Rel—The relative accuracy desired. (Default: Err_Rel = ε1/2, where ε is the machine precision)
Smooth—If present and nonzero, uses a nonadaptive rule to compute the integral.
Integration of Two-dimensional Iterated Integrals
This method integrates two-dimensional iterated integrals.
Input Parameters
f—A scalar string specifying the name of a user-supplied PV-WAVE function to be integrated. Function f accepts two scalar parameters and returns a single scalar of the same type.
a—A scalar expression specifying the lower limit of the outer integral.
b—A scalar expression specifying the upper limit of the outer integral.
h—The name of a user-supplied PV-WAVE function used to evaluate the lower limit of the inner integral. Function h accepts one scalar parameter and returns a single scalar of the same type.
g—The name of a user-supplied PV-WAVE function used to evaluate the upper limit of the inner integral. Function g accepts one scalar parameter and returns a single scalar of the same type.
Synopsis
Triggered by the use of the parameters g and h and keyword Two_Dimensional in addition to f, a, and b.
result = INTFCN(f, a, b, g, h, /Two_Dimensional)
Returned Value
result—The value of:
If no value can be computed, NaN is returned.
Keywords
In addition to the keywords listed in the Global Keywords section, the following keyword is available and must be specified for this method:
Two_Dimensional—If present and nonzero, integrates a two-dimensional iterated integral.