QROMB

The QROMB function evaluates the integral of a function over the closed interval [ A, B ] using Romberg integration. The result will have the same structure as the smaller of A and B , and the resulting type will be single- or double-precision floating, depending on the input types.

QROMB is based on the routine qromb described in section 4.3 of Numerical Recipes in C: The Art of Scientific Computing (Second Edition), published by Cambridge University Press, and is used by permission.

Calling Sequence

Result = QROMB( Func, A, B )

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 closed interval [ A, B ].

For example, if we wish to integrate the cubic polynomial

y = x 3 + ( x - 1) 2 + 3

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

FUNCTION cubic, X

  RETURN, X^3 + (X - 1.0)^2 + 3.0

END

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.

Keywords

DOUBLE

Set this keyword to force the computation to be done in double-precision arithmetic.

EPS

The desired fractional accuracy. For single-precision calculations, the default value is 1.0  ¥  10 -6 . For double-precision calculations, the default value is 1.0  ¥  10 -12 .

JMAX

2 (JMAX - 1) is the maximum allowed number of steps. If this keyword is not specified, a default of 20 is used.

K

Integration is performed by Romberg's method of order 2K. If not specified, the default is K=5. (K=2 is Simpson's rule).

Example

To integrate the CUBIC function (listed above) over the interval [0, 3] and print the result:

PRINT, QROMB('cubic', 0.0, 3.0)

IDL prints:

 32.2500

This is the exact solution.

See Also

INT_2D , INT_3D , INT_TABULATED , QROMO , QSIMP