Home  /  Resources & support  /  FAQs  /  Calculating the Euler–Mascheroni constant

How do I get the Euler–Mascheroni constant gamma = 0.57721... in Stata?

Title   Calculating the Euler–Mascheroni constant
Author Nicholas J. Cox, Durham University, UK

The Euler–Mascheroni constant gamma = 0.57721 ... is one of the most important constants in mathematics. For some background, see Havil (2003) and/or Finch (2003, 28–40). In statistics, gamma arises, for example, in the theory of certain probability distributions.

In Stata, gamma can be calculated using the function digamma() as -digamma(1) (note the negative sign). For example,

        . di %12.10f -digamma(1) 

yields 0.5772156649. See also math functions for details about related functions.


Finch, S. R. 2003. Mathematical Constants.
Cambridge: Cambridge University Press.
Havil, J. 2003. Gamma: Exploring Euler's Constant.
Princeton: Princeton University Press.