R programming: How do I get Euler's number?

早过忘川 提交于 2021-02-17 14:29:37

问题


For example, how would I go about entering the value e^2 in R?


回答1:


The R expression

exp(1)

represents e, and

exp(2)

represents e^2.

This works because exp is the exponentiation function with base e.




回答2:


-digamma(1) is the Euler's Constant in R.

e, (exp(1) in R), which is the natural base of the natural logarithm

Euler's Constant. Euler's Number




回答3:


if you want to have a little number e to play with, you can also make one yourself:

    emake <- function(){
        options("warn"=-1)
        e <- 0
        for (n in 0:2000){
            e <- e+ 1/(factorial(n))
        }
        return(e)
    }
    e <- emake()
    e^10
    exp(10)

    # or even:
    e <- sum(1/factorial(0:100)) 

fun stuff



来源:https://stackoverflow.com/questions/9458536/r-programming-how-do-i-get-eulers-number

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!