home *** CD-ROM | disk | FTP | other *** search
- DEF FNqsimp(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 Simpson's rule
- REM :
- LOCAL EPS, JMAX%, OST, OS, J%, DONE%, ST
- EPS=1E-4: JMAX%=20
- OST=-1E30: OS=-1E30
- REM :
- FOR J% = 1 TO JMAX%
- PRINT J%
- ST = FNtrapzd(A,B,J%)
- SS=(4*ST-OST)/3
- IF ABS(SS-OS) < EPS*ABS(OS) THEN DONE% = TRUE: J%=JMAX%
- OS=SS
- OST=ST
- NEXT J%
- IF DONE% = TRUE THEN =SS
- PRINT "Too many steps": STOP
-
- *******Must append FNtrapzd
- -- to which FNarg must be attached.