Subject: [ maxima-Bugs-609464 ] 1+%e,numer and %e^%e,numer
From: Dieter Kaiser
Date: Wed, 20 May 2009 23:35:05 +0200
Am Mittwoch, den 20.05.2009, 22:47 +0200 schrieb Harald Geyer:
> I just wonder why numer is implemented the way it is and if we can come
> up with something better ...
>
> Currently there are quite some bugs/inconsistencies like in the following
> example:
> Maxima 5.18post http://maxima.sourceforge.net
> Using Lisp CLISP 2.44.1 (2008-02-23)
> Distributed under the GNU Public License. See the file COPYING.
> Dedicated to the memory of William Schelter.
> The function bug_report() provides bug reporting information.
> (%i1) display2d:false;
> (%o1) false
> (%i2) 1,numer;
> (%o2) 1
> (%i3) sin(0);
> (%o3) 0
> (%i4) sin(0), numer;
> (%o4) 0.0
>
> Note that numer is intended to return numerical but exact answers where
> possible (hance %o2 seems correct) but %o4 is a float!
Because 0 is changed to 0.0 when numer is TRUE the sin function returns
a floating point result. This is the way almost all functions are
implemented. E.g. gamma(1) gives 1, but gamma(1),numer and gamma(1.0)
will give 1.0 and gamma(1.0b0) will give 1.0b0.
> I wonder why numerical evaluation can't be performed from inner parts of
> expressions to outer parts. i.e. in sin(%e^(%e+1)) first look at
> %e+1, evaluate this to a float if numer=true, then look at %e^some_float
> and always evaluate it, because it already is a float and finally look
> at sin(some_other_float) ...
That is the way the code of the simplifer does the evaluation to get a
numerical result when we implement the proposed additional code.
> As an orthogonal issue: Why is numer a flag (I personally don't recall
> ever setting it to true for anything beside tests, but I often use it
> on the prompt like "foo, numer" but numer(foo) would work for me too).
> If it wasn't a flag perhaps we wouldn't need to handle it in the
> core simplifier.
The numerical evaluation of all implemented functions depends on the
mechanism of $numer. There is a lot of code which has to be changed when
we introduce a new concept.
A further remark:
On my slowest system with CLISP the testsuite has a run time of about
1050 seconds and calls simplifya about 2*10^7 times. The contribution of
the extra tests for $numer and $%enumer I have estimated to be less than
1 second. (I have written some special test functions to measure the
effect.)
So, I think the effect of the extra test is negligible.
Dieter Kaiser