#
# loggamma-func.txt, 15 Apr 10

!msgpostfix Log(gamma function), Numerical recipes in C: 1988\n

!need all
 76.18009173
-86.50532033
 24.01409822
- 1.231739516
  0.120858003e-2
- 0.536382e-5

  2.50662827465

# ALNGAM computes the logarithm of the Gamma function.
#    Algorithm AS 245:
#    A Robust and Reliable Algorithm for the Logarithm of the Gamma Function,
#    Applied Statistics,
#    Volume 38, Number 2, 1989, pages 397-402.

!fuzz 0.0000001

!msgpostfix Log(gamma function), Applied statistics algorithm 245\n

!need all
-  2.66685511495E+00
- 24.4387534237E+00
- 21.9698958928E+00
  11.1667541262E+00
   3.13060547623E+00
   0.607771387771E+00
  11.9400905721E+00
  31.4690115749E+00
  15.2346874070E+00

- 78.3359299449E+00
-142.046296688E+00
 137.519416416E+00
  78.6994924154E+00
   4.16438922228E+00
  47.0668766060E+00
 313.399215894E+00
 263.505074721E+00
  43.3400022514E+00

-  2.12159572323E+05
   2.30661510616E+05
   2.74647644705E+04
-  4.02621119975E+04
-  2.29660729780E+03
-  1.16328495004E+05
-  1.46025937511E+05
-  2.42357409629E+04
-  5.70691009324E+02

   0.279195317918525E+00
   0.4917317610505968E+00
   0.0692910599291889E+00
   3.350343815022304E+00
   6.012459259764103E+00


# Calculates the natural logarithm of GAMMA ( X ) for positive X.
#    William Cody, Kenneth Hillstrom,
#    Chebyshev Approximations for the Natural Logarithm of the 
#    Gamma Function,
#   Mathematics of Computation,
#    Volume 21, Number 98, April 1967, pages 198-203.
#
#    Kenneth Hillstrom,
#    ANL/AMD Program ANLC366S, DGAMMA/DLGAMA,
#    May 1969.
#
#    John Hart, Ward Cheney, Charles Lawson, Hans Maehly, 
#    Charles Mesztenyi, John Rice, Henry Thacher, 
#    Christoph Witzgall,
#    Computer Approximations,
#    Wiley, 1968,
#    LC: QA297.C64.
#

!msgpostfix Log(gamma function(x)) for posiitve x, via Chebyshex approximation\n

!need all
-1.910444077728E-03
 8.4171387781295E-04
-5.952379913043012E-04
 7.93650793500350248E-04
-2.777777777777681622553E-03
 8.333333333333333331554247E-02
 5.7083835261E-03

 4.945235359296727046734888E+00
 2.018112620856775083915565E+02
 2.290838373831346393026739E+03
 1.131967205903380828685045E+04
 2.855724635671635335736389E+04
 3.848496228443793359990269E+04
 2.637748787624195437963534E+04
 7.225813979700288197698961E+03

 4.974607845568932035012064E+00
 5.424138599891070494101986E+02
 1.550693864978364947665077E+04
 1.847932904445632425417223E+05
 1.088204769468828767498470E+06
 3.338152967987029735917223E+06
 5.106661678927352456275255E+06
 3.074109054850539556250927E+06

 1.474502166059939948905062E+04
 2.426813369486704502836312E+06
 1.214755574045093227939592E+08
 2.663432449630976949898078E+09
 2.940378956634553899906876E+10
 1.702665737765398868392998E+11
 4.926125793377430887588120E+11
 5.606251856223951465078242E+11

 6.748212550303777196073036E+01
 1.113332393857199323513008E+03
 7.738757056935398733233834E+03
 2.763987074403340708898585E+04
 5.499310206226157329794414E+04
 6.161122180066002127833352E+04
 3.635127591501940507276287E+04
 8.785536302431013170870835E+03

 1.830328399370592604055942E+02
 7.765049321445005871323047E+03
 1.331903827966074194402448E+05
 1.136705821321969608938755E+06
 5.267964117437946917577538E+06
 1.346701454311101692290052E+07
 1.782736530353274213975932E+07
 9.533095591844353613395747E+06

 2.690530175870899333379843E+03
 6.393885654300092398984238E+05
 4.135599930241388052042842E+07
 1.120872109616147941376570E+09
 1.488613728678813811542398E+10
 1.016803586272438228077304E+11
 3.417476345507377132798597E+11
 4.463158187419713286462081E+11

#    Christian Lanczos,
#    A precision approximation of the gamma function,
#    SIAM Journal on Numerical Analysis, B,
#    Volume 1, 1964, pages 86-96.

!msgpostfix Compute Log(Gamma(X)) using a Lanczos approximation\n

!need all
    0.9999999999995183E+00
  676.5203681218835E+00
-1259.139216722289E+00
  771.3234287757674E+00
- 176.6150291498386E+00
   12.50734324009056E+00
-   0.1385710331296526E+00
    0.9934937113930748E-05
    0.1659470187408462E-06

# The Cephes Math Library tables are very long and not listed here..
# The positive domain is partitioned into numerous segments for approximation.
# For x > 10,
# log gamma(x) = (x - 0.5) log(x) - x + log sqrt(2 pi) + 1/x R(1/x^2)
# Near the minimum at x = x0 = 1.46... the approximation is
# log gamma(x0 + z) = log gamma(x0) + z^2 P(z)/Q(z)
# for small z.
# Elsewhere between 0 and 10,
# log gamma(n + z) = log gamma(n) + z P(z)/Q(z)
# for various selected n and small z.

!fuzz 0.0000001

!msgpostfix Lanczos Gamma Function approximation - coefficients\n

!need all
  1.000000000190015
 76.18009172947146
-86.50532032941677
 24.01409824083091
- 1.231739572450155
  0.1208650973866179E-2
- 0.5395239384953E-5

