floor(log(4)/log(2)) = 1 ??



On Sat, Apr 26, 2008 at 11:21 PM, Robert Dodier <robert.dodier at gmail.com>
wrote:

> On 4/26/08, Oliver Kullmann <O.Kullmann at swansea.ac.uk> wrote:
>
> >  floor(log(4) / log(2));
> Yeah. Me neither. This bug has been reported before;
> do we know what's going on here? Is someone working on it?
>

For arguments which aren't obviously rational, floor calculates the
argument's value at various precisions, and if the floors agree, it uses
that value.  This is not a reliable method when the argument is in fact
exactly an integer. It would be better if it could calculate the argument
using true interval arithmetic (with pessimistic rounding etc.), but Maxima
cannot currently perform interval arithmetic. Of course, with that method,
many cases would remain unsimplified (e.g. floor(sin(1)^2+cos(1)^2)), since
the interval would typically straddle the exact result.  Better that than
the wrong result, but still frustrating.  In general, there is no algorithm
that will always give the correct result (a result related to Goedel's
theorem).

Barton Willis has been working on this.

>  Furthermore, I couldn't find any simplification rule which would yield
log(4) / log(2) = 2 ??

Radcan specializes in algebraic dependencies like this, but doesn't always
give the simplest result. Barton and I have talked about using radcan-like
techniques for log expressions, but I don't know what the state of the code
is. And of course many other cases (trig, nested radicals) wouldn't be
handled by this.



>  What seems to me absolutely indispensable is  a general
"simplify"-function, which in some reasonable
>  way applies *all* simplification rules (without fear  that it takes a bit
longer --- finding out about
>  such errors etc. takes much longer :-().

There are several problems with this.  Putting aside the theoretical result
that it is in general impossible, there is the practical problem that
"simplest" isn't well-defined.  We agree that log(4)/log(2) is more
complicated then 2, but which is the simplest of the following:

      sin(%pi/8), sqrt(sqrt(2)-1)/2^(3/4), or sqrt(1-sqrt(2)/2)/sqrt(2) ?

On the other hand, as Robert says, there is lots of room for improving our
documentation....

           -s