INTFCNHYPER Function (PV-WAVE Advantage)
Integrates a function on a hyper-rectangle as follows:
Usage
result = INTFCNHYPER(f, a, b)
Input Parameters
f—Scalar string specifying the user-supplied function to be integrated. Function f accepts as input an array of data points at which the function is to be evaluated and returns the scalar value of the function.
a—One-dimensional array containing the lower limits of integration.
b—One-dimensional array containing the upper limits of integration.
Returned Value
result—The value of the hyper-rectangle function is returned. If no value can be computed, NaN is returned.
is returned. If no value can be computed, NaN is returned.
Input Keywords
Err_Abs—Absolute accuracy desired. Default: Err_Abs = SQRT(ε), where ε is the machine precision
Err_Rel—Relative accuracy desired. Default: Err_Rel = SQRT(ε), where ε is the machine precision
Max_Evals—Number of evaluations allowed. Default: Max_Evals is the lesser of 256n and 2563, where n is the number of independent variables of f.
Output Keywords
Err_Est—Named variable into which an estimate of the absolute value of the error is stored.
Discussion
Function INTFCNHYPER approximates the following n-dimensional iterated integral:
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 ith 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.
Example
In this example, the integral of:
is computed on an expanding cube. The values of the error estimates are machine dependent. The exact integral over R is π3/2.
.RUN
; Define the function to be integrated.
- FUNCTION f, x
- RETURN, EXP(-TOTAL(x^2))
- END
; Compute the exact value of the integral.
limit = !Pi^1.5
PM, ' Limit:', limit
; PV-WAVE prints: Limit: 5.56833
; Compute values of the integral over expanding cubes and
; output the results after each call to INTFCNHYPER.
FOR i = 1L, 6 DO BEGIN $
a = [-i/2., -i/2., -i/2.] &$
b = [i/2., i/2., i/2.] &$
ans = INTFCNHYPER('f', a, b) &$
PRINT, 'integral = ', ans, ' limit = ', limit
; The output for this is:
; 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—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.
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.