home *** CD-ROM | disk | FTP | other *** search
- DEF FNgammln(XX)
- REM :
- REM Returns the value of Gamma(XX) for XX>0. Full accuracy is obtained
- REM for XX>1. For 0<XX<1, the reflection formula can be used first.
- REM This is done in next line:
- IF XX<1 THEN =LN(PI*(1-XX)) - FNgammln(2-XX) - LN(SIN(PI*(1-XX)))
- REM :
- REM Ref: Numerical Recipes (Fortran), p 157 and 704.
- REM Lanczos's formula.
- REM :
- LOCAL COF(), X, TMP, SER
- DIM COF(6)
- REM :
- COF(1)=76.18009173: COF(2)=-86.50532033: COF(3)=24.01409822
- COF(4)=-1.231739516: COF(5)=0.120858003E-2: COF(6)=-0.536382E-5
- X=XX-1: TMP=X+5.5: TMP=(X+0.5)*LN(TMP)-TMP: SER=1
- FOR J%=1 TO 6
- X=X+1: SER=SER+COF(J%)/X
- NEXT J%
- REM:
- =TMP+LN(2.50662827465*SER)
-