Is Euler–Mascheroni's constant $\gamma \approx 0.577$ available in R, similarly to $\pi$ with pi
or $e$ with exp(1)
?
是否Eu-Mascheroni在R中可用$ \ gamma \约0.577 $,类似于$ \ pi $与pi或$ e $与exp(1)?
3 个解决方案
#1
19
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.
从数学上讲,我们可以将感兴趣的常数写为在1处评估的伽马函数的导数的负值.R具有伽玛函数的导数作为digamma,因此它只是插入这个问题。
-digamma(1)
#[1] 0.5772157
#2
3
Like this:
喜欢这个:
eulergamma = 0.57721566490153 # just copy from e.g. wiki to whatever precision you need it
Now use it ;)
现在用它;)
#3
-1
print(-digamma(1), digits=22 )
#1
19
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.
从数学上讲,我们可以将感兴趣的常数写为在1处评估的伽马函数的导数的负值.R具有伽玛函数的导数作为digamma,因此它只是插入这个问题。
-digamma(1)
#[1] 0.5772157
#2
3
Like this:
喜欢这个:
eulergamma = 0.57721566490153 # just copy from e.g. wiki to whatever precision you need it
Now use it ;)
现在用它;)
#3
-1
print(-digamma(1), digits=22 )