Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Euler–Mascheroni's constant in R?

Tags:

r

Is Euler–Mascheroni's constant $\gamma \approx 0.577$ available in R, similarly to $\pi$ with pi or $e$ with exp(1)?

like image 570
QuantIbex Avatar asked Aug 07 '13 14:08

QuantIbex


2 Answers

Mathmatically we can write the constant of interest as the negative of the derivative of the gamma function evaluated at 1. R has the derivative of the gamma function as digamma so it's just a matter of plugging this in.

-digamma(1)
#[1] 0.5772157
like image 75
Dason Avatar answered Oct 14 '22 13:10

Dason


Like this:

eulergamma = 0.57721566490153 # just copy from e.g. wiki to whatever precision you need it

Now use it ;)

like image 42
eddi Avatar answered Oct 14 '22 15:10

eddi