HTBasic Help
×
Menu
Index
Simpson
Integrate a function using Simpson's rule.
 
 
Loading        LOADSUB ALL FROM "SIMPSON.HTS"
or LOADSUB FROM "MATHLIB.HTS"
or LOADSUB FNSimpson FROM "MATHLIB.HTS"
 
Usage                REAL A,B,X
INTEGER N
X=FNSimpson(F$,A,B,N)
 
Description                
FNSimpson estimates the integral of the function named in F$ between the points a and b where N is the number of divisions between a and b. The estimate is exact for functions that can be represented as polynomials of degree 2 or less.
 
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                
FNSimpson 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.