18

I just fight few hours trying to implement some physics calculation.

Then, I discovered everything was wrong, just because Math.log is not about log10 but ln.

I would expect Math.ln() = ln and Math.log() = log10. But absolutly not Math.log() = ln !!!

Why did they make it so confusing ?

New Developer
  • 3,245
  • 10
  • 41
  • 78
user1219721
  • 783
  • 1
  • 8
  • 16
  • This isn't really the kind of question for this site. – mash Jan 27 '13 at 16:14
  • 3
    Because programmers are not mathematicians! – Antony Jan 27 '13 at 16:15
  • 1
    See this question for additional information: http://stackoverflow.com/questions/3019278/any-way-to-specify-the-base-of-math-log-in-javascript – dash Jan 27 '13 at 16:17
  • The e-logarithm is the natural logarithm and has much more elegant properties. We humans only use the 10-logarithm because we (usually) have 10 fingers... By that logic, it is the right thing to reserve `log` for the *truly* natural logarithm. – Mattias Buelens Jan 27 '13 at 16:20
  • 2
    @Antony Actually, mathematicians use `log` for the natural logarithm, so that's something programmers have in common with mathematicians. – Daniel Fischer Jan 27 '13 at 16:59
  • I can relate with your frustration man! – Siddhartha Apr 21 '15 at 23:44

2 Answers2

6

Mathematicians commonly use logarithms with a base of e for convenience. They don't take into account the distinction between the natural log and the common log; they use a single logarithmic function log because in higher mathematics the use of Euler constant is very common.

David G
  • 94,763
  • 41
  • 167
  • 253
4

This is the convention in academic mathematics.

Emanuele Paolini
  • 9,912
  • 3
  • 38
  • 64