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

  1. DEF FNgammln(XX)
  2. REM :
  3. REM Returns the value of Gamma(XX) for XX>0.  Full accuracy is obtained 
  4. REM for XX>1.  For 0<XX<1, the reflection formula can be used first.
  5. REM This is done in next line:
  6.    IF XX<1 THEN =LN(PI*(1-XX)) - FNgammln(2-XX) - LN(SIN(PI*(1-XX)))
  7. REM :
  8. REM Ref: Numerical Recipes (Fortran), p 157 and 704.
  9. REM      Lanczos's formula.
  10. REM :
  11.    LOCAL COF(), X, TMP, SER
  12.    DIM COF(6)
  13. REM :
  14.    COF(1)=76.18009173:  COF(2)=-86.50532033:   COF(3)=24.01409822
  15.    COF(4)=-1.231739516: COF(5)=0.120858003E-2: COF(6)=-0.536382E-5 
  16.    X=XX-1: TMP=X+5.5: TMP=(X+0.5)*LN(TMP)-TMP: SER=1
  17.    FOR J%=1 TO 6
  18.       X=X+1: SER=SER+COF(J%)/X
  19.    NEXT J%
  20. REM:
  21. =TMP+LN(2.50662827465*SER)
  22.