 
 : stirling-fact ( n -- fact )
     [ pi 2 * * sqrt ]
-    [ dup e / swap ^ ]
-    [ 12 * recip 1 + ]
-    tri * * ;
+    [ [ e / ] keep ^ ]
+    [ 12 * recip 1+ ] tri * * ;
+

    #! gamma(x) = integral 0..inf [ t^(x-1) exp(-t) ] dt
    #! gamma(n+1) = n! for n > 0
    dup { [ 0.0 <= ] [ 1.0 mod zero? ] } 1&& [
            drop 1./0.
        ] [
            dup abs gamma-lanczos6 swap dup 0 > [ drop ] [ gamma-neg ] if
    ] if ;

: gammaln ( x -- gamma[x] )
    #! gammaln(x) is an alternative when gamma(x)'s range
    #! varies too widely
    dup 0 < [
            drop 1./0.
        ] [
            dup abs gammaln-lanczos6 swap dup 0 > [ drop ] [ gamma-neg ] if
    ] if ;

: nth-root ( n x -- y )
    [ recip ] dip swap ^ ;

! Forth Scientific Library Algorithm #1
!

: gamma-p6
    {
        2.50662827563479526904 225.525584619175212544 -268.295973841304927459
        80.9030806934622512966 -5.00757863970517583837 0.0114684895434781459556
    } ; inline

: gamma-z ( x n -- seq )
