Dec 16, 2009 at 7:26pm


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!


Dec 16, 2009 at 9:11pm

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 at 10:11pm

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)]


Dec 16, 2009 at 10:13pm

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 at 12:17am

let see first if my version of expr really can do what i suggested. :P

Dec 17, 2009 at 5:21pm

expr log($f1)/log(2)


expr log10($f1)/log10(2)


expr ln($f1)/ln(2)

Dec 18, 2009 at 3:51am

Thank you for that precious help!

loga(x) = logb(x)/logb(a)

This is fascinating…


Sep 4, 2012 at 3:01pm

thx to luke hall also from me.

Jul 3, 2013 at 7:28pm

Is it ever too late for thank you? I think not. Thanks for the math lesson Luke.


You must be logged in to reply to this topic.