home *** CD-ROM | disk | FTP | other *** search
- DEF FNqtrap(A,B)
- REM Returns the integral of the function FNarg(X) from A to B.
- REM The parameter EPS can be set to the desired fractional accuracy
- REM and JMAX% so that 2^(JMAX%-1) is the maximum allowed number of
- REM steps. Integration is performed by the trapezoidal rule.
- REM :
- LOCAL EPS, JMAX%, OLDS, I%, DONE%
- EPS = 1E-6: JMAX% = 20
- OLDS=-1E30 :REM any number unlikely to be the mean of the
- REM function at its endpoints will do here.
- FOR I%=1 TO JMAX%
- S = FNtrapzd(A,B,I%)
- IF ABS(S-OLDS) < EPS*ABS(OLDS) THEN DONE% = TRUE: I%=JMAX%
- OLDS=S
- NEXT I%
- IF DONE% = TRUE THEN =S
- PRINT "Too many steps": STOP
-
- *******Must append FNtrapzd
- -- to which FNarg must be attached.