128

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

3 Answers 3

200

The R expression

exp(1)

represents e, and

exp(2)

represents e^2.

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

34

-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

7
  • 7
    Please do not edit the question to change its terminology. The fact that 25000 people have visited this page without complaint until now suggests to me that many people read "Euler's constant" to mean e, and if you change the title, future searchers will fail to find this page. Also, glancing at wikipedia, it seems this reading of "Euler's constant" is quite widespread (since there's even a note at the top of the page you linked to the page for e).
    – Frank
    Commented Jan 20, 2016 at 21:31
  • 8
    @Frank Hey Frank. Thank you for reply, but I don't agree with you. I don't agree the logic that "most people called "e" as Euler's constant and thus we should called it the same way on stackoverflow". Math is a subtle subject and the terminology really matters. I have right and responsibility to tell people here the truth instead of letting them called it whatever they want. The note above wiki's page doesn't indicate that these two terms are identical, instead, the note is there because many people don't know the difference between those two constants.
    – Oldyoung
    Commented Jan 20, 2016 at 21:45
  • 2
    @Frank I believe many people search for the answer for euler's constant but find this one, disappointing search somewhere else just like me. I feel we should did the same thing, put a comment says that if you are looking for e (natural base of the natural logarithm), click here. Actually by looking the detail of question, it is the person who ask this question don't know the difference between e and euler's constant. I feel uncomfortable that we have a question with title doesn't agree with content..
    – Oldyoung
    Commented Jan 20, 2016 at 21:48
  • 7
    OK, I've changed the title to Euler's Number as it seems like what the OP meant judging by the accepted answer. I guess there is no need for this answer anymore? Or at least you could rephrase it in some manner. Commented Jan 20, 2016 at 22:22
  • 10
    @DavidArenburg I edited. I am just so surprised that I am blamed (downvote) for telling someone my knowledge, here, in stack overflow. Think about this: OP might still call "e" Euler's constant right now, just because nobody here want to tell him the difference of terms or everybody here just don't care. Sorry I was math major in college so maybe that's why I am little more sensitive to the so called "terminology". I know stack overflow is a place for solving practical issues, but I am still surprised that how different people value things due to their major or background. not to judge
    – Oldyoung
    Commented Jan 21, 2016 at 17:39
22

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

2
  • 4
    Courtesy of user gla: "Last line must be e<- sum(1/factorial(0:100)) (and not 1:100)" - your last line is off by 1, yielding 1.718...
    – Sam Firke
    Commented May 2, 2015 at 14:47
  • 8
    thanks! edited! took 3 years, alas, open peer review always comes around!
    – tim riffe
    Commented May 2, 2015 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.