HTBasic Help
×
Menu
Index
Romberg
Integrate a function using Romberg's method.
 
Loading        LOADSUB ALL FROM "ROMBERG.HTS"
or LOADSUB FROM "MATHLIB.HTS"
or LOADSUB FNRomberg FROM "MATHLIB.HTS"
 
Usage                REAL A,B,X,Eps
INTEGER Nmin,Nmax
X=FNRomberg(F$,A,B,Eps,Nmin,Nmax)
 
Description                
FNRomberg estimates the integral of the function named in F$ between the points a and b. Eps, Nmin, and Nmax control when the estimating process stops. FNRomberg evaluates the integral using successively more points in the function, doing at least Nmin evaluations of the integral. When the difference between successive values of the integral is less than Eps, integration stops. If FNRomberg does more than Nmax evaluations of the integral without successive evaluations differing by less that Eps, FNRomberg stops evaluating the integral and returns MAXREAL to indicate failure to evaluate the integral.
 
F$ should contain the name of an HTBasic subroutine. The subroutine should take two REAL parameters. It should evaluate the function to be integrated at the second parameter and return its value in the first parameter. For example, if F$ = "Test", then the subroutine Test should begin with the definition line
 
SUB Test(REAL Y,X)
 
where X and Y may be replaced by the names of any REAL parameters. The subroutine Test would evaluate the desired function at the value X and return the value in Y.
 
Errors                
FNRomberg causes an HTBasic error if the subroutine named in F$ is undefined. The subroutine named in F$ may also cause HTBasic Errors when it is evaluated.