Arbitrary-precision computation of the gamma function

We discuss the best methods available for computing the gamma function Γ(z) in arbitrary-precision arithmetic with rigorous error bounds. We address different cases: rational, algebraic, real or complex arguments; large or small arguments; low or high precision; with or without precomputation. The methods also cover the log-gamma function log Γ(z), the digamma function ψ(z), and derivatives Γ(n)(z) and ψ(n)(z). Besides attempting to summarize the existing state of the art, we present some new formulas, estimates, bounds and algorithmic improvements and discuss implementation results.

[1]  H. Behnke,et al.  Theorie der analytischen Funktionen einer komplexen Veränderlichen , 1965 .

[2]  Technisch-Naturwissenschaftliche Fakultät,et al.  Fast and Rigorous Computation of Special Functions to High Precision , 2014 .

[3]  Nico M. Temme,et al.  Numerical methods for special functions , 2007 .

[4]  Edward W. Ng A Comparison of Computational Methods and Algorithms for the Complex Gamma Function , 1975, TOMS.

[5]  Richard P. Brent,et al.  Multiple-precision zero-finding methods and the complexity of elementary function evaluation , 1975, ArXiv.

[6]  Richard P. Brent,et al.  Fast computation of Bernoulli, Tangent and Secant numbers , 2011, ArXiv.

[7]  Warren D. Smith The Gamma function revisited , 2006 .

[8]  Éric Schost,et al.  On the evaluation of some sparse polynomials , 2017, Math. Comput..

[9]  D. Owen Handbook of Mathematical Functions with Formulas , 1965 .

[10]  Comments on "Exactification of Stirling's approximation for the logarithm of the gamma function" , 2014, 1406.1320.

[11]  Jean-Michel Muller,et al.  Modern Computer Arithmetic , 2016, Computer.

[12]  Richard P. Brent,et al.  Fast Multiple-Precision Evaluation of Elementary Functions , 1976, JACM.

[13]  Kurt Siegfried Kölbig,et al.  Programs for computing the logarithm of the gamma function, and the digamma function, for complex argument. , 1984 .

[14]  Jonathan M. Borwein,et al.  Fast evaluation of the gamma function for small rational fractions using complete elliptic integrals of the first kind , 1992 .

[15]  Paul Zimmermann,et al.  Accuracy of Mathematical Functions in Single, Double, Extended Double and Quadruple Precision , 2021 .

[16]  J. Wrench,et al.  Concerning Two Series for the Gamma Function , 1968 .

[17]  M. Hussein,et al.  New Asymptotic Formulae for the Point Coulomb Phase Shift , 2011 .

[18]  F. R. Villegas Experimental Number Theory , 2007 .

[19]  Joris van der Hoeven,et al.  Fast Evaluation of Holonomic Functions , 1999, Theor. Comput. Sci..

[20]  Jonathan M. Borwein,et al.  Computational strategies for the Riemann zeta function , 2000 .

[21]  C. G. van der Laan,et al.  Calculation of special functions: the gamma function, the exponential integrals and error-like functions , 1984 .

[22]  D. Bailey MPFUN2020: A new thread-safe arbitrary precision package (Full Documentation) , 2021 .

[23]  G. Nemes,et al.  New asymptotic expansion for the Gamma function , 2010 .

[24]  Ricardo P'erez-Marco Notes on the historical bibliography of the gamma function. , 2020, 2011.12140.

[25]  Jinhee Yi,et al.  Theta-function identities and the explicit formulas for theta-function and their applications , 2004 .

[26]  Nelson H. F. Beebe,et al.  The Mathematical-Function Computation Handbook , 2017, Springer International Publishing.

[27]  Peter Borwein Reduced complexity evaluation of hypergeometric functions , 1987 .

[28]  David M. Smith Algorithm 814: Fortran 90 software for floating-point multiple precision arithmetic, gamma and related functions , 2001, TOMS.

[29]  J. Spouge Computation of the gamma, digamma, and trigamma functions , 1994 .

[30]  P. Davis Leonhard Euler's Integral: A Historical Profile of the Gamma Function: In Memoriam: Milton Abramowitz , 1959 .

[31]  J. Rice On the L ∞ Walsh Arrays for Γ(x) and Erfc(x) , 1964 .

[32]  Ronald F. Boisvert,et al.  NIST Handbook of Mathematical Functions , 2010 .

[33]  Glendon Ralph Pugh AN ANALYSIS OF THE LANCZOS GAMMA APPROXIMATION , 2004 .

[34]  R. Brent ON THE ACCURACY OF ASYMPTOTIC APPROXIMATIONS TO THE LOG-GAMMA AND RIEMANN–SIEGEL THETA FUNCTIONS , 2016, Journal of the Australian Mathematical Society.

[35]  Matthew F. Causley,et al.  The gamma function via interpolation , 2021, Numerical Algorithms.

[36]  D. E. G. Hare,et al.  Computing the Principal Branch of log-Gamma , 1997, J. Algorithms.

[37]  David Harvey,et al.  A multimodular algorithm for computing Bernoulli numbers , 2008, Math. Comput..

[38]  F. Olver Asymptotics and Special Functions , 1974 .

[39]  G. Nemes Error bounds and exponential improvements for the asymptotic expansions of the gamma function and its reciprocal , 2013, Proceedings of the Royal Society of Edinburgh: Section A Mathematics.

[40]  Milton Abramowitz,et al.  Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables , 1964 .

[41]  E. Salamin,et al.  Computation of π Using Arithmetic-Geometric Mean , 1976 .

[42]  Christoph Quirin Lauter,et al.  Metalibm: A Mathematical Functions Code Generator , 2014, ICMS.

[43]  S. Chowla,et al.  An "exact" formula for the m-th Bernoulli number , 1972 .

[44]  Fredrik Johansson,et al.  A bound for the error term in the Brent-McMillan algorithm , 2013, Math. Comput..

[45]  Bruce W. Char,et al.  On Stieltjes’ continued fraction for the gamma function , 1980 .

[46]  Cetin Hakimoglu An Algorithm for the Derivation of Rapidly Converging Infinite Series for Universal Mathematical Constants , 2009, SSRN Electronic Journal.

[47]  Richard P. Brent,et al.  Error bounds on complex floating-point multiplication , 2007, Math. Comput..

[48]  Christoph Quirin Lauter,et al.  Semi-Automatic Floating-Point Implementation of Special Functions , 2015, 2015 IEEE 22nd Symposium on Computer Arithmetic.

[49]  Jonathan M. Borwein,et al.  Pi and the AGM , 1999 .

[50]  Annie A. M. Cuyt,et al.  Handbook of Continued Fractions for Special Functions , 2008 .

[51]  Edmund Taylor Whittaker,et al.  A Course of Modern Analysis , 2021 .

[52]  Avraham Adler,et al.  Lambert-W Function , 2015 .

[53]  Lloyd N. Trefethen,et al.  Computing the Gamma Function Using Contour Integrals and Rational Approximations , 2007, SIAM J. Numer. Anal..

[54]  Marc Mezzarobba,et al.  Autour de l'évaluation numérique des fonctions D-finies , 2011 .

[55]  William J. Cody,et al.  Algorithm 715: SPECFUN–a portable FORTRAN package of special function routines and test drivers , 1993, TOMS.

[56]  Weiping Wang Unified approaches to the approximations of the gamma function , 2016 .

[57]  Georges Schwachheim,et al.  Algorithm 309: Gamma function with arbitrary precision , 1967, CACM.

[58]  R. Spira Calculation of the Gamma Function by Stirling's Formula , 1971 .

[59]  William J. Cody,et al.  Performance evaluation of programs related to the real gamma function , 1991, TOMS.

[60]  Raghu Kacker,et al.  Digital Library of Mathematical Functions , 2003 .

[61]  H. T. Kung,et al.  Fast Algorithms for Manipulating Formal Power Series , 1978, JACM.

[62]  C. Lanczos,et al.  A Precision Approximation of the Gamma Function , 1964 .

[63]  Sven Köhler,et al.  On the Stability of Fast Polynomial Arithmetic , 2008 .

[64]  Shinya Miyajima Verified computation of matrix gamma function , 2020, ArXiv.

[65]  Randall A. Snyder Double , 2020, Definitions.

[66]  Sidney A. Morris Tweaking Ramanujan's Approximation of n! , 2021, Fundamental Journal of Mathematics and Applications.

[67]  Richard P. Brent,et al.  Some New Algorithms for High-Precision Computation of Euler’s Constant , 1980 .

[68]  Michel Waldschmidt,et al.  Transcendence of Periods: The State of the Art , 2006 .

[69]  Fredrik Johansson,et al.  Evaluating parametric holonomic sequences using rectangular splitting , 2013, ISSAC.

[70]  Martin Ziegler,et al.  Fast (Multi-)Evaluation of Linearly Recurrent Sequences: Improvements and Applications , 2005, ArXiv.

[71]  Fredrik Johansson,et al.  Faster Arbitrary-Precision Dot Product and Matrix Multiplication , 2019, 2019 IEEE 26th Symposium on Computer Arithmetic (ARITH).

[72]  F. W. J. Olver,et al.  On the Asymptotic Solution of Second-Order Differential Equations Having an Irregular Singularity of Rank One, with an Application to Whittaker Functions , 1965 .

[73]  Y. Nesterenko Modular functions and transcendence questions , 1996 .

[74]  L. Fekih-Ahmed On the Power Series Expansion of the Reciprocal Gamma Function , 2014, 1407.5983.

[75]  Jonathan M. Borwein,et al.  Gamma and Factorial in the Monthly , 2017, Am. Math. Mon..

[76]  Leili Rafiee Sevyeri,et al.  Stirling’s Original Asymptotic Series from a Formula Like One of Binet’s and its Evaluation by Sequence Acceleration , 2018, Exp. Math..

[77]  Peter B. Borwein,et al.  On the Complexity of Calculating Factorials , 1985, J. Algorithms.

[78]  C. Mortici A new fast asymptotic series for the gamma function , 2015 .

[79]  S. Chowla,et al.  On Epstein's Zeta Function (I). , 1949, Proceedings of the National Academy of Sciences of the United States of America.

[80]  THE MPFR LIBRARY: ALGORITHMS AND PROOFS , 2006 .

[81]  R. Paris,et al.  Exponentially-improved asymptotics for the gamma function , 1992 .

[82]  R. Vidunas EXPRESSIONS FOR VALUES OF THE GAMMA FUNCTION , 2004, math/0403510.

[83]  Yudell L. Luke,et al.  Evaluation of the Gamma Function by Means of Padé Approximations , 1970 .

[84]  W. Boyd,et al.  Gamma function asymptotics by an extension of the method of steepest descents , 1994, Proceedings of the Royal Society of London. Series A: Mathematical and Physical Sciences.

[85]  A. MacLeod,et al.  Algorithm AS 245: A Robust and Reliable Algorithm for the Logarithm of the Gamma Function , 1989 .

[86]  Staffan Wrigge,et al.  High-precision values of the gamma function and of some related coefficients , 1980 .

[87]  Piet Van Mieghem Binet's factorial series and extensions to Laplace transforms , 2021 .

[88]  W. J. Cody,et al.  Chebyshev Approximations for the Natural Logarithm of the Gamma Function , 1967 .

[89]  Vincent Lefèvre,et al.  MPFR: A multiple-precision binary floating-point library with correct rounding , 2007, TOMS.

[90]  Chao Chen A more accurate approximation for the gamma function , 2016 .

[91]  Jean-Michel Muller,et al.  Handbook of Floating-Point Arithmetic (2nd Ed.) , 2018 .

[92]  Fredrik Johansson Efficient Implementation of Elementary Functions in the Medium-Precision Range , 2015, 2015 IEEE 22nd Symposium on Computer Arithmetic.

[93]  Fredrik Johansson,et al.  Computing Hypergeometric Functions Rigorously , 2016, ACM Trans. Math. Softw..

[94]  Joel Brewster Lewis,et al.  Skyscraper Numbers , 2013, 1304.6445.

[95]  D. V. Chudnovsky,et al.  Approximations and complex multiplication according to Ramanujan , 2000 .

[96]  Fredrik Johansson,et al.  Short Addition Sequences for Theta Functions , 2016, J. Integer Seq..

[97]  Amir Sadeghi,et al.  Computation of matrix gamma function , 2018, BIT Numerical Mathematics.

[98]  Harvey,et al.  Integer multiplication in time O(n log n) , 2021, Annals of Mathematics.

[99]  Peter McCullagh A rapidly convergent series for computing () and its derivatives , 1981 .

[100]  Abraham Ziv,et al.  Fast evaluation of elementary mathematical functions with correctly rounded last bit , 1991, TOMS.

[101]  Xavier Gourdon,et al.  Introduction to the Gamma Function , 2002 .

[102]  SANDRA FILLEBROWN,et al.  Faster Computation of Bernoulli Numbers , 1992, J. Algorithms.

[103]  Hirondo Kuki,et al.  Complex gamma function with error control , 1972, CACM.

[104]  Fredrik Johansson,et al.  Arb: Efficient Arbitrary-Precision Midpoint-Radius Interval Arithmetic , 2016, IEEE Transactions on Computers.

[105]  Cecil Hastings,et al.  Approximations for digital computers , 1955 .

[106]  Iaroslav V. Blagouchine Two series expansions for the logarithm of the gamma function involving Stirling numbers and containing only rational coefficients for certain arguments related to π−1 , 2014, 1408.3902.

[107]  K. Roberts,et al.  Thesis , 2002 .