Talk:Binary logarithm

From Wikipedia, the free encyclopedia
Jump to: navigation, search
WikiProject Mathematics (Rated GA-class, Low-importance)
WikiProject Mathematics
This article is within the scope of WikiProject Mathematics, a collaborative effort to improve the coverage of Mathematics on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Mathematics rating:
GA Class
Low Importance
 Field: Analysis


Where did the algorithm given here come from? I would love to find an original reference for this. Kleg 22:45, 19 July 2006 (UTC)

Same here. I can sort of guess why it works (squaring the scaled input value corresponds to doubling the result), but I would love to see the actual maths behind it.

Math for the result is located at this url:

not a function! A function has a domain, a range, and a graph!


Where does the name lg come from? --Abdull (talk) 20:15, 24 July 2008 (UTC)

I also wonder. In all my books lb x is used.--MathFacts (talk) 20:26, 16 August 2009 (UTC)
lg = log10. the correct symbol for binary logarithm is lb = log2 — Preceding unsigned comment added by (talk) 19:47, 24 August 2016 (UTC)
For values of correct meaning "recommended by a standards organization" rather than what people actually use, maybe. —David Eppstein (talk) 21:06, 24 August 2016 (UTC)

Error in identity?[edit]

Isn't there an error in the identity given for integers?

It says:

But surely it should be:

? —Preceding unsigned comment added by (talk) 12:05, 26 February 2010 (UTC)

python example[edit]

Python example is clearly too complex and too long. 1exec1 (talk) 17:53, 24 April 2010 (UTC)

Then refer to the OLD python code, it is much simpler


from __future__ import division

def log2(X):
  epsilon = 1.0/(10**12)
  while X < 1:
    integer_value = integer_value - 1
    X = X * 2
  while X >= 2:
    integer_value = integer_value + 1
    X = X / 2
  decfrac = 0.0
  partial = 0.5
  while partial > epsilon:
    if X >= 2:
      decfrac = decfrac + partial
      X = X / 2
    partial = partial / 2
  return (integer_value + decfrac)

if __name__ == '__main__':
  value = 4.5
  print "     X  =",value
  print "LOG2(X) =",log2(value)

# Sample output
#    $ python 
#         X  = 4.5
#    LOG2(X) = 2.16992500144

C example[edit]

wouldn't it be nicer code to use


instead of

if (n >= 1<<16) { n >>= 16; pos += 16; }
if (n >= 1<< 8) { n >>=  8; pos +=  8; }
if (n >= 1<< 4) { n >>=  4; pos +=  4; }
if (n >= 1<< 2) { n >>=  2; pos +=  2; }
if (n >= 1<< 1) {           pos +=  1; }

? -- (talk) 11:53, 16 July 2010 (UTC)

Yes, I agree. The point of an article like this is to explain how a binary logarithm works, not to show some super-optimized and confusing C version. On the other hand, no one really writes anything in C anymore, unless it needs to run really fast... Moxfyre (ǝɹʎℲxoɯ | contrib) 15:28, 16 July 2010 (UTC)

the notation lb is used without an introduction[edit]

Under "Information Theory" the notation lb rather than ld is suddenly used without explanation. Is this a typo? If not, perhaps it should say something like: lg, lx, and lb are sometimes used for base 2 logs.

GA Review[edit]

This review is transcluded from Talk:Binary logarithm/GA1. The edit link for this section can be used to add comments to the review.

Reviewer: Jfhutson (talk · contribs) 21:31, 28 December 2015 (UTC)

This looks like it's probably already at GA standards. Here are my comments:

  • lead formula: specify that x is the binary log of n.
  • Starting with five examples seems excessive.
  • italicize the Elements
  • "On this basis, Michael Stifel has been credited with publishing the first known table of binary logarithms, in 1544." Last comma not needed.
  • wikilink Jain
  • rather than listing some logarithmic identities, why not say it obeys all logarithmic identities unless some are particularly relevant here.
  • you really started to lose me with big O notation. Is there a way to make this more accessible?
  • likewise with bioinformatics

That'll do for now. I don't know if any of that should hold up the GA. I'll take another look today or tomorrow. My main issue is where the article drifts into specialized subjects without explaining enough for a non-specialist.--JFH (talk) 21:31, 28 December 2015 (UTC)

  • Several duplicate links. Check out this tool. Not really a GA issue though. --JFH (talk) 01:13, 29 December 2015 (UTC)
  • Images: I'm pretty sure the calculator logo qualifies as de minimis, so no problems I can see.
  • I'm going to go ahead and pass the article with the recommendation that my comments be addressed, but I don't think they rise to the level of GA. The prose is clear and concise even if some of the subject matter is difficult for a non-specialist. --JFH (talk) 14:03, 29 December 2015 (UTC)
    • Thanks! I'll definitely be revising this article to take your feedback into account. —David Eppstein (talk) 18:16, 29 December 2015 (UTC)