The IMSL_INTFCNHYPER function integrates a function on a hyper-rectangle as follows:

This routine requires an IDL Advanced Math and Stats license. For more information, contact your sales or technical support representative.

An estimate of the error is returned in the optional keyword ERR_EST. The approximation is achieved by iterated applications of product Gauss formulas. The integral is first estimated by a two-point, tensor-product formula in each direction. Then, for (i = 0, ..., n – 1 ), the function calculates a new estimate by doubling the number of points in the i-th direction, but halving the number immediately afterwards if the new estimate does not change appreciably. This process is repeated until either one complete sweep results in no increase in the number of sample points in any dimension, the number of Gauss points in one direction exceeds 256, or the number of function evaluations needed to complete a sweep exceeds MAX_EVALS.


This example computes the integral of:

on an expanding cube. The values of the error estimates are machine dependent. The exact integral over R is π3/2.

; Define the function to be integrated.
limit = !Pi^1.5
; Compute the exact value of the integral.
PM, '	Limit:', limit

IDL prints:

Limit:	5.56833


FOR i = 1,6 DO	BEGIN $
a = [-i/2., -i/2., -i/2.] & $
b = [i/2., i/2., i/2.] & $
ans = IMSL_INTFCNHYPER('f', a, b) & $
PRINT, 'integral = ', ans, ' limit = ', limit
; Compute values of the integral over expanding cubes and
; output the results after each call to IMSL_INTFCNHYPER. 

IDL prints:

integral = 0.785213
limit = 5.56833
integral =  3.33231
limit = 5.56833
integral =  5.02107
limit = 5.56833
integral =  5.49055
limit = 5.56833
integral =  5.56135
limit = 5.56833
integral =  5.56771
limit = 5.56833


Warning Errors

MATH_MAX_EVALS_TOO_LARGE: The keyword MAX_EVALS was set too large.

Fatal Errors

MATH_NOT_CONVERGENT: Maximum number of function evaluations has been reached, and convergence has not been attained.


The integration methods supported by IMSL_INTFCN may generate any of the following errors.

Warning Errors

MATH_ROUNDOFF_CONTAMINATION: Roundoff error, preventing the requested tolerance from being achieved, has been detected.

MATH_PRECISION_DEGRADATION: Degradation in precision has been detected.

MATH_EXTRAPOLATION_ROUNDOFF: Roundoff error in the extrapolation table, preventing requested tolerance from being achieved, has been detected.

MATH_EXTRAPOLATION_PROBLEMS: Extrapolation table, constructed for convergence acceleration of the series formed by the integral contributions of the cycles, does not converge to the requested accuracy.

MATH_BAD_INTEGRAND_BEHAVIOR: Bad integrand behavior occurred in one or more cycles.

Fatal Errors

MATH_DIVERGENT: Integral is probably divergent or slowly convergent.

MATH_MAX_SUBINTERVALS: Maximum number of subintervals allowed has been reached.

MATH_MAX_CYCLES: Maximum number of cycles allowed has been reached.

MATH_MAX_STEPS: Maximum number of steps allowed have been taken. The integrand is too difficult for this routine.


Result = IMSL_INTFCNHYPER(F, A, B [, ERR_ABS=value] [, ERR_EST=variable] [, ERR_REL=value] [, MAX_EVALS=value])

Return Value

The value of the hyper-rectangle function is returned. If no value can be computed, the floating-point value NaN (Not a Number) is returned.



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 scalar expression specifying the lower limit of integration.


A scalar expression specifying the upper limit of integration.


ERR_ABS (optional)

Set this keyword to a value specifying the accuracy desired. The default value is SQRT(ε), where ε is the machine precision.

ERR_EST (optional)

Set this keyword to a named variable that will contain an estimate of the absolute value of the error.

ERR_REL (optional)

Set this keyword to a value specifying the relative accuracy desired. The default value is SQRT(ε), where ε is the machine precision.

MAX_EVALS (optional)

Set this keyword to a scalar value specifying the number of evaluations allowed. The default value is 1,000,000 for n ≤ 2 and 256n for n > 2, where n is the number of independent variables of f.

Version History



See Also