skip to main content
article
Free access

A Note on a Method of Computing the Gamma Function

Published: 01 October 1960 Publication History

Abstract

Numerous formulas are available for the computation of the Gamma function [1, 2]. The purpose of this note is to indicate the value of a well-known method that is easily extended for higher accuracy requirements.
Using the recursion formula for the Gamma function, Γ(x + 1) = xΓ(x), (1) and Stirling's asymptotic expansion for ln Γ(x) [3], we have ln Γ(x) ∼ (x - 1/2) ln x - x + 1/2 ln 2π + ∑Nr=1 Cr/x2r-1. (2) It follows that, if k and N are appropriately selected positive integers, Γ(x + 1) can be represented by Γ(x + 1) ∼ √2π exp (x + k - 1/2) ln (x + k) - (x + k) exp ∑Nr=1 Cr/(x + k)2r-1/(x + 1)(x + 2) … (x + k - 1) (3) where Cr = (- 1)r-1 Br/(2r - 1)(2r), Br being the Bernoulli numbers [4]. These coefficients have been published by Uhler [5].
Requiring the range 0 ≦ x ≦ 1 is no restriction since, if necessary, Γ(x + 1) can be generated for other arguments using (1).
For a given N, the error in (2) can be estimated from |ε| < |CN+1|/x2N+1. (4)
The curves of Figure 1 show contours of constant error bound as a function of N and x. These curves represent single and double-precision floating-arithmetic requirements of ε < 5·10-9 and ε < 5·10-17. For a given N, k is defined as the minimum integral x greater than or equal to those on the curves. Then N and k can be chosen to minimize round-off and computing time.
For N and k equal to 4, formula (3) yields Γ(x + 1) ∼ √2π exp (x + 4 - 1/2) ln (x + 4) - (x + 4) exp ∑4r=1Cr/(x + 4)2r-1/(x + 1)(x + 2)(x + 3). (5)
A similar expression suitable for double precision results for N = 8 and k = 9.
The exponents in (5) are split to reduce roundoff. Various algebraic manipulations might result in a further reduction of roundoff.

References

[1]
CECIL HASTINGS, JR, Approxtmattons for Digital Computers, p 158. Princeton Umverslty Press, Princeton, N J.
[2]
C. LANCZOS, Trigonometric interpolation of empirical and analytic functions J Math Phys 17 (1938), 123-199
[3]
M. E SHERRY AND S FULDA, Calculation of Gamma functions to high accuracy, Math Tables Azds Compz~t 13 (1959), 314-315
[4]
F T WHITTAKER AND G N. WATSON, A Course. of Modern Analysis, p 125 Cambridge University Press, Cambridge, Englund.
[5]
HORACE S UHLER, The coefficients of Stirling's serms for log F(x), Proc Nat. Acad Scz. 28 (1942), 59-62

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Journal of the ACM
Journal of the ACM  Volume 7, Issue 4
Oct. 1960
111 pages
ISSN:0004-5411
EISSN:1557-735X
DOI:10.1145/321043
Issue’s Table of Contents

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 October 1960
Published in JACM Volume 7, Issue 4

Permissions

Request permissions for this article.

Check for updates

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 405
    Total Downloads
  • Downloads (Last 12 months)34
  • Downloads (Last 6 weeks)7
Reflects downloads up to 21 Oct 2024

Other Metrics

Citations

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media