home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 1 / ARM_CLUB_CD.iso / contents / apps / maths / progs / maths1 / Brian / polint / qsimp < prev    next >
Encoding:
Text File  |  1989-07-20  |  652 b   |  23 lines

  1. DEF FNqsimp(A,B)
  2. REM Returns the integral of the function FNarg(X) from A to B. 
  3. REM The parameter EPS can be set to the desired fractional accuracy
  4. REM and JMAX% so that 2^(JMAX%-1) is the maximum allowed number of
  5. REM steps.  Integration is performed by Simpson's rule
  6. REM :
  7. LOCAL EPS, JMAX%, OST, OS, J%, DONE%, ST
  8. EPS=1E-4: JMAX%=20
  9. OST=-1E30: OS=-1E30
  10. REM :
  11. FOR J% = 1 TO JMAX%
  12.    PRINT J%
  13.    ST = FNtrapzd(A,B,J%)
  14.    SS=(4*ST-OST)/3
  15.    IF ABS(SS-OS) < EPS*ABS(OS) THEN DONE% = TRUE: J%=JMAX%
  16.    OS=SS
  17.    OST=ST
  18. NEXT J%
  19. IF DONE% = TRUE THEN =SS
  20. PRINT "Too many steps": STOP 
  21.  
  22. *******Must append FNtrapzd 
  23.        -- to which FNarg must be attached.