Skip to main content

The gamma function via interpolation


A new computational framework for evaluation of the gamma function Γ(z) over the complex plane is developed. The algorithm is based on interpolation by rational functions, and generalizes the classical methods of Lanczos (SIAM J. Numer. Anal. B 1:86–96, (1964) and Spouge (SIAM J. Numer. Anal., 31(3):931–944, (1994) (which we show are also interpolatory). This framework utilizes the exact poles of the gamma function. By relaxing this condition and allowing the poles to vary, a near-optimal rational approximation is possible, which is demonstrated using the adaptive Antoulous Anderson (AAA) algorithm, developed in Nakatsukasa et al. (Appl. Math. Comp., 40:1494-1522, (2016)) and Nakatsukasa and Trefethen (SIAM J. Sci. Comp., 42(5):A3157–A3179, (2020)). The resulting approximations are competitive with Stirling’s formula in terms of overall efficiency.

This is a preview of subscription content, access via your institution.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6


  1. 1.

    Despite the mismatch in arguments, Legendre’s notation Γ(z) has prevailed over Gauss’ notation π(z) = Γ(z + 1), which satisfies π(n) = n!. Although in certain cases [19, 38] the notation z! = Γ(z + 1) is instead adopted, to avoid confusion.

  2. 2.

    The integral of the first kind defines the beta function B(α,β) = Γ(α)Γ(β)/Γ(α + β).

  3. 3.

    in fact, this series is due to De Moivre. The series obtained by Stirling is

    $$ \ln z! \sim \ln(\sqrt{2\pi})+ Z\ln Z-Z+\sum\limits_{k\geq 1} \frac{B_{2k}\left( \frac{1}{2}\right)}{2k(2k-1)} \frac{1}{Z^{2k-1}}, \quad Z = z+\frac{1}{2}, $$

    which is slightly more accurate. See [11, 14].

  4. 4.

    Named after Jacob Bernoulli; Daniel was his nephew.

  5. 5.

    At least not explicitly. But this property is used indirectly in [30] and [22] to compute expansion coefficients.


  1. 1.

    Abramowitz, M., Stegun, I.: Handbook of Mathematical Functions, with Formulas, Graphs, and Mathematical Tables. Dover Publications, Inc., New York (1974)

    MATH  Google Scholar 

  2. 2.

    Andrews, G.E., Askey, R., Roy, R.: Special Functions, Encyclopedia of Mathematics and its Applications. Cambridge University Press, Cambridge (2000)

    Google Scholar 

  3. 3.

    Aptekarev, A.I., Yattselev, M.L.: Pade approximants for functions with branch points — strong asymptotics of Nuttall–Stahl polynomials. Acta Mathematica 215(2), 217–280 (2015)

    MathSciNet  Article  Google Scholar 

  4. 4.

    Artin, E.: The gamma function. Dover (2015)

  5. 5.

    Bateman, H., Erdélyi, A.: Higher transcendental functions, Higher Transcendental Functions, no. v. 1 Dover Publications (2006)

  6. 6.

    Berljafa, M., Güttel, S.: The rkfit algorithm for nonlinear rational approximation. SIAM J. Sci. Comp. 39(5), A2049–A2071 (2017)

    MathSciNet  Article  Google Scholar 

  7. 7.

    Borwein, J.M., Corless, R.M.: Gamma and factorial in the monthly. Amer. Math. Monthly 125(5), 400–424 (2018)

    MathSciNet  Article  Google Scholar 

  8. 8.

    Boyd, W.G.C.: Gamma function asymptotics by an extension of the method of steepest descents. Proc. R. Soc. Lond. A 447, 609–630 (1994)

    MathSciNet  Article  Google Scholar 

  9. 9.

    Cardoso, J.R., Sadeghi, A.: Computation of matrix gamma function. BIT Numer. Math., pp. 1–28 (2019)

  10. 10.

    Carrier, G.F., Krook, M., Pearson, C.E.: Functions of a Complex Variable: Theory and Technique (Classics in Applied Mathematics). SIAM, Philadelphia (2005)

    Book  Google Scholar 

  11. 11.

    Corless, R.M., Sevyeri, L.R.: Stirling’s original asymptotic series from a formula like one of binet’s and its evaluation by sequence acceleration. Exp. Math. 0(0), 1–8 (2019)

    Article  Google Scholar 

  12. 12.

    Davis, P.J.: Leonhard Euler’s integral: A historical profile of the gamma function: In memoriam: Milton abramowitz. Amer. Math. Monthly 66(10), 849–869 (1959)

    MathSciNet  MATH  Google Scholar 

  13. 13.

    Dubuc, S.: An approximation of the gamma function. J. Math. Anal. Appl. 146(2), 461–468 (1990)

    MathSciNet  Article  Google Scholar 

  14. 14.

    Dutka, J.: The early history of the factorial function. Arch. for Hist. of Ex. Sci. 43(3), 225–249 (1991)

    MathSciNet  Article  Google Scholar 

  15. 15.

    Godfrey, P.: A note on the computation of the convergent lanczos complex gamma approximation., 2001, Accessed: 2019-03-20

  16. 16.

    Gronau, D.: Why is the gamma function so as it is. Teach Math. Comput. Sci. 1, 43–53 (2003)

    Article  Google Scholar 

  17. 17.

    Gustavsen, B., Semlyen, A.: Rational approximation of frequency domain responses by vector fitting. IEEE Trans. on Power Delivery 14(3), 1052–1061 (1999)

    Article  Google Scholar 

  18. 18.

    Hare, D.E.G.: Computing the principal branch of log-gamma. J. Alg. 25(2), 221–236 (1997)

    MathSciNet  Article  Google Scholar 

  19. 19.

    Lanczos, C.: A precision approximation of the gamma function. SIAM J. Numer. Anal. B 1, 86–96 (1964)

    MathSciNet  MATH  Google Scholar 

  20. 20.

    Li, X., Chen, C.P.: Padé approximant related to asymptotics for the gamma function. Jour. Ineq. Appl. 2017(1), 1–13 (2017)

    Article  Google Scholar 

  21. 21.

    Luke, Y.L.: The special functions and their approximations, ISSN Elsevier Science (1969)

  22. 22.

    Luke, Y.L.: Mathematical functions and their approximations. Elsevier Science (2014)

  23. 23.

    Mortici, C.: Best estimates of the generalized stirling formula. Appl. Math. Comp. 215, 4044–4048 (2010)

    MathSciNet  Article  Google Scholar 

  24. 24.

    Nakatsukasa, Y., Sète, O., Trefethen, L.: The aaa algorithm for rational approximation. Siam. J. Sci. Comp. 40, 1494–1522 (2016)

    MathSciNet  Article  Google Scholar 

  25. 25.

    Nakatsukasa, Y., Trefethen, L.N.: An algorithm for real and complex rational minimax approximation. SIAM J. Sci. Comp. 42(5), A3157–A3179 (2020)

    MathSciNet  Article  Google Scholar 

  26. 26.

    Nemes, G.: On the coefficients of the asymptotic expansion of n. J. Int. Seq. 13, 1–5 (2010)

    MathSciNet  MATH  Google Scholar 

  27. 27.

    Nemes, G.: Error bounds and exponential improvements for the asymptotic expansions of the gamma function and its reciprocal. Proceedings of the Royal Society of Edinburgh: Section A Mathematics 145(3), 571–596 (2015)

    MathSciNet  Article  Google Scholar 

  28. 28.

    Press, W.H., Teukolsky, S.A., Vetterling, W.T., Flannery, B.P.: Numerical Recipes 3Rd Edition: The Art of Scientific Computing, 3rd edn. Cambridge University Press, New York (2007)

    MATH  Google Scholar 

  29. 29.

    Pérez-marco, R.: Notes on the historical bibliography of the gamma function (2020)

  30. 30.

    Pugh, G.R.: An Analysis of the Lanczos Gamma Approximation. Ph.D. thesis, University of British Columbia (2004)

  31. 31.

    Reinartz, K.D.: Chebychev interpolations of the gamma and polygamma functions and their analytical properties (2016)

  32. 32.

    Remmert, R.: Wielandt’s theorem about the γ-function. Amer. Math. Monthly 103(3), 214–220 (1996)

    MathSciNet  MATH  Google Scholar 

  33. 33.

    Rump, S.M.: Verified sharp bounds for the real gamma function over the entire floating-point range. Nonlin. Th. Appl., IEICE 5(3), 339–348 (2014)

    Article  Google Scholar 

  34. 34.

    Schmelzer, T., Trefethen, L.N.: Computing the gamma function using contour integrals and rational approximations. Siam J. Numer. Anal. 45(2), 558–571 (2007)

    MathSciNet  Article  Google Scholar 

  35. 35.

    Sebah, P., Gourdon, X.: Introduction to the gamma function (2002)

  36. 36.

    Smith, D.M.: Algorithm 814: Fortran 90 software for floating-point multiple precision arithmetic, gamma and related functions. ACM Trans. Math. Softw. 27(4), 377–387 (2001). (English)

    Article  Google Scholar 

  37. 37.

    Smith, W.: The gamma function revisited. Math. Comp. 58, 1–20 (2006)

    Google Scholar 

  38. 38.

    Spouge, J.L.: Computation of the gamma, digamma, and trigamma functions. SIAM J. Numer. Anal. 31(3), 931–944 (1994)

    MathSciNet  Article  Google Scholar 

  39. 39.

    Stahl, H.: The convergence of padé approximants to functions with branch points. Jour. Approx. Theory 91(2), 139–204 (1997)

    Article  Google Scholar 

  40. 40.

    Trefethen, L.N., Weideman, J.A.C., Schmelzer, T.: Talbot quadratures and rational approximations. BIT Numer. Math. 46(3), 653–670 (2006)

    MathSciNet  Article  Google Scholar 

  41. 41.

    Wang, W.: Unified approaches to the approximations of the gamma function. J. Num. Theory 163, 570–595 (2016)

    MathSciNet  Article  Google Scholar 

  42. 42.

    Whittaker, E.T., Watson, G.N.: A course of modern analysis. Cambridge University Press, Cambridge (1996)

    Book  Google Scholar 

  43. 43.

    Xu, K., Jiang, S.: A bootstrap method for sum-of-poles approximations. J. Sci. Comp. 55(1), 16–39 (2013)

    MathSciNet  Article  Google Scholar 

Download references


The author is very grateful to an anonymous peer reviewer for several key suggestions that greatly improved the quality of this manuscript. The author is especially indebted for the suggestion to examine the AAA algorithm.

Author information



Corresponding author

Correspondence to Matthew F. Causley.

Additional information

Publisher’s note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Reprints and Permissions

About this article

Verify currency and authenticity via CrossMark

Cite this article

Causley, M.F. The gamma function via interpolation. Numer Algor (2021).

Download citation


  • Gamma function
  • Lanczos approximation
  • Spouge approximation
  • Stirling series
  • Interpolation
  • AAA approximation