log2


    Dec 16 2009 | 7:26 pm
    Hi, I just can't figure out how I can evaluate log base 2. With [expr log($f1)], the log seems natural. log2($f1) is refused.
    Thanks for your help!
    NP

    • Dec 16 2009 | 9:11 pm
      expr log($f1,2)
      you give the base as second value, the values are separated by a comma, and commas must be "escaped" by a backslash.
    • Dec 16 2009 | 10:11 pm
      In the [expr] object it seems that log() and ln() bother calculate the natural logarithm. When I try putting two arguments into log() I get an error saying it only understands one argument.
      What you want to do is use the base changing rule of logarithms which states loga(x) = (logb(x)/logb(a)) where the emphasised letters represent the base of the logarithm. So if you want to be in base two use something like:
      [expr log10($f1)/log10(2)]
      lh
    • Dec 16 2009 | 10:13 pm
      Hey, in my version of expr that doesn't work. That's why I always do it like this: expr log10($f1)/log10(2).
    • Dec 17 2009 | 12:17 am
      let see first if my version of expr really can do what i suggested. :P
    • Dec 17 2009 | 5:21 pm
      expr log($f1)/log(2)
      or
      expr log10($f1)/log10(2)
      or
      expr ln($f1)/ln(2)
    • Dec 18 2009 | 3:51 am
      Thank you for that precious help!
      loga(x) = logb(x)/logb(a)
      This is fascinating...
      NP
    • Sep 04 2012 | 3:01 pm
      thx to luke hall also from me.
    • Jul 04 2013 | 2:28 am
      Is it ever too late for thank you? I think not. Thanks for the math lesson Luke.