For example, how would I go about entering the value e^2 in R?
Asked
Active
Viewed 2.2e+01k times
3 Answers
194
The R expression
exp(1)
represents e, and
exp(2)
represents e^2.
This works because exp
is the exponentiation function with base e.

Adam Mihalcin
- 14,242
- 4
- 36
- 52
33
-digamma(1)
is the Euler's Constant in R.
e
, (exp(1)
in R), which is the natural base of the natural logarithm

Oldyoung
- 567
- 4
- 8
-
7Please 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 Jan 20 '16 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 Jan 20 '16 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 Jan 20 '16 at 21:48
-
1I'm not saying "most" because really I do not know; I think we can confidently say "many" and should be hesitant to change titles of questions that have been visited frequently. I see your point about accurate terminology, but am not sure if accuracy should trump (i) the apparently significant frequency of this confusion and (ii) the OP's original understanding and intent, even if they were wrong. Yeah, with a little more rep, you can leave a comment there. If you want to discuss further or get broader input, one of us could make a post on "meta": http://meta.stackoverflow.com/ – Frank Jan 20 '16 at 21:57
-
7OK, 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. – David Arenburg Jan 20 '16 at 22:22
-
9@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 Jan 21 '16 at 17:39
-
After almost 3 years, I am glad to see 10 more upvote for this answer. Independent thinking is important, yet a lot of times we just accept what was taught to us... like this stupid Euler's Constant vs Euler's Number... Does it matter? probably not that much, but what about other things? Maybe America will be different if everyone care little bit more and think little bit more..(I am not from America :)) – Oldyoung Jun 29 '18 at 20:20
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

tim riffe
- 5,651
- 1
- 26
- 40
-
4Courtesy 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 May 02 '15 at 14:47
-
8thanks! edited! took 3 years, alas, open peer review always comes around! – tim riffe May 02 '15 at 14:59