QROMO

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 open interval (2, ∞) and prints the result:

PRINT, QROMO('hyper', 2.0, /MIDEXP)

IDL prints:

 0.0412050

Note: When using the MIDEXP keyword, the upper integration limit is assumed to be infinity and is not supplied.

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).

For example, if we wish to integrate the fourth-order polynomial

y = 1 / x4

we define a function HYPER to express this relationship in the IDL language:

FUNCTION hyper, X

   RETURN, 1.0 / X^4

END

Note: If QROMO is complex then 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 should not be supplied by the user.

MIDINF

Use the midinf() function (see Numerical Recipes, section 4.4) as the integrating function.

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.

MIDSQU

Use the midsqu() function (see Numerical Recipes, section 4.4) as the integrating function.

Version History

4.0

Introduced

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