The QROMO function evaluates the integral of a function over the open interval (A, B) using a modified Romberg’s method.
Examples
Consider the following function:
function hyper, x
return, 1.0 / x^4
end
This example integrates the HYPER function over the interval (2, 100) and prints the result:
print, qromo('hyper', 2.0, 100)
IDL prints:
0.0416656
Syntax
Result = QROMO(Func, A [, B] [, /DOUBLE] [, EPS=value] [, JMAX=value] [, K=value] [, /MIDEXP | , /MIDINF | , /MIDPNT | , /MIDSQL | , /MIDSQU] )
Return Value
Returns the integral of the function.
Arguments
Func
A scalar string specifying the name of a user-supplied IDL function to be integrated. This function must accept a single scalar argument X and return a scalar result. It must be defined over the open interval (A, B). See above for an example.
Note: If Func returns a complex result, only the real part is used for the computation.
A
The lower limit of the integration. A can be either a scalar or an array.
B
The upper limit of the integration. B can be either a scalar or an array. If the MIDEXP keyword is specified, B is assumed to be infinite, and should not be supplied by the user.
Note: If arrays are specified for A and B, then QROMO integrates the user-supplied function over the interval [Ai, Bi] for each i. If either A or B is a scalar and the other an array, the scalar is paired with each array element in turn.
Keywords
DOUBLE
Set this keyword to force the computation to be done in double-precision arithmetic.
EPS
The fractional accuracy desired, as determined by the extrapolation error estimate. For single-precision calculations, the default value is 1.0 x 10-6. For double-precision calculations, the default value is 1.0 x 10-12.
JMAX
Set to specify the maximum allowed number of mid quadrature points to be 3(JMAX - 1). The default value is 14.
K
Integration is performed by Romberg’s method of order 2K. If not specified, the default is K=5.
MIDEXP
Use the midexp() function (see Numerical Recipes, section 4.4) as the integrating function. If the MIDEXP keyword is specified, argument B is assumed to be infinite and will be ignored.
Note: The MIDEXP keyword is designed to be used with functions that fall off exponentially rapidly at infinity. If your function does not fall off exponentially, you should consider using a different method.
MIDINF
Use the midinf() function (see Numerical Recipes, section 4.4) as the integrating function. MIDINF automatically uses a change of variables from x to 1/x.
Note: The MIDINF keyword is designed for use with either a B parameter that is large and positive (close to infinity), or an A parameter that is large and negative, but not both. To work properly, A and B should both have the same sign.
MIDPNT
Use the midpnt() function (see Numerical Recipes, section 4.4) as the integrating function. This is the default if no other integrating function keyword is specified.
MIDSQL
Use the midsql() function (see Numerical Recipes, section 4.4) as the integrating function. MIDSQL is designed for use with an integral that has an integrable power-law singularity at the A limit.
MIDSQU
Use the midsqu() function (see Numerical Recipes, section 4.4) as the integrating function. MIDSQU is designed for use with an integral that has an integrable power-law singularity at the B limit.
Version History
Resources and References
QROMO is based on the routine qromo described in section 4.4 of Numerical Recipes in C: The Art of Scientific Computing (Second Edition), published by Cambridge University Press, and is used by permission.
See Also
INT_2, INT_3D, INT_TABULATED, QROMB, QSIMP