Sorry if this seems like a dumb question, but what what type of logarithm is $\log$ in Wikipedia articles? Cheers.


2 Answers 2


I think it depends on the situation. For a mathematician, $\log n$ probably means the natural logarithm. For a computer scientist, $\log n$ probably denotes the base $2$ logarithm, etc.

I think sometimes people write $\ln x$ for the natural logarithm, $\lg x$ for the base $2$ logarithm and $\log x$ for the base $10$ logarithm.

For programming languages such as Matlab, Python, Julia, $\log x$ means the natural logarithm of $x$.

Do you have a specific Wikipedia article that contains $\log$?

  • $\begingroup$ Yes: en.wikipedia.org/wiki/Tf%E2%80%93idf $\endgroup$ Aug 18, 2018 at 9:37
  • 3
    $\begingroup$ I think for that article, the base of the logarithm does not matter. See here. $\endgroup$
    – zdm87
    Aug 18, 2018 at 10:07
  • $\begingroup$ I deleted your "This is intended to be a comment" disclaimer, since this is the answer. $\endgroup$ Aug 18, 2018 at 10:20
  • 1
    $\begingroup$ For a computer scientist, $\log$ doesn't always mean base-$2$. Like everything else, it depends on context. For example, I'm a computer scientist but I work with probability as well as numbers of bits so I would guess I actually use natural and base-2 logs equally often. $\endgroup$ Aug 18, 2018 at 10:23
  • $\begingroup$ @zbir Thanks for a nice paper(I use Stanford Information Retrieval). That's what come in to my mind, after I posted it, that it may not matter:) $\endgroup$ Aug 18, 2018 at 15:55

It depends entirely on context. In mathematics as a whole, $\log$ usually denotes the natural logarithm (base $\mathrm{e}$). In computer science, the situation isn't as clean because we often want to talk about things like a number of bits or the height of a binary tree and, in those cases, the most natural (*baddum-tsh*) logarithm to use is base-$2$. Some authors use $\ln$ and $\lg$ to explicitly denote base-$\mathrm{e}$ and base-$2$ logs, respectively; many authors just write $\log$ to mean whatever base is most appropriate for the situation.

Of course, Wikipedia is written by a huge number of unconnected authors, so you can't assume any consistent convention is used. Indeed, a careful Wikipedia editor would make sure that $\log$ is used consistently within an article, but you can't rely on everyone being careful.

It usually doens't matter. Changing the base of a logarithm just multiplies the answer by a constant factor because, for all $a,b>1$ and all $x>0$, $$\log_a x = \frac{\log_b x}{\log_b a}\,.$$ In many situations, this multiplicative factor of $1/\log_b a$ isnt at all important. In the context of a big-$O$, big-$\Theta$, big-$\Omega$ etc bound, $O(\log n)$ means the same thing regardless of the base, since big-$O$ disregards constant factors. (But note that, e.g., $2^{\log_2 x}=x$, whereas $2^{\log_3 x}=x^{1/\log_2 3}\approx x^{1.58}$ so there are situations in which the base makes a big difference.)

Your specific example. In a comment, you say you're specifically interested in the page about tf-idf. I know nothing about document retrieval but my understanding from skim-reading that article is as follows. We're interested in ranking documents according to their relevance, and the relevance of a document is given by a score of the form $x\log y$, where $x$ and $y$ are statistics of the document. Since changing the base of the logarithm just multiplies all the scores by a constant, it doesn't change the ranking order. Therefore, it doesn't matter what base you use for the logarithm in this situation.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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