Am Donnerstag, den 28.01.2010, 05:27 -0600 schrieb Barton Willis:
> Thank you for the guidance--I'll refine simplim%signum. In general, maybe
> the limit
> code could call the simplim function sooner?
Maxima calls for every function like sin, log, ... and for the operators
"+", "*", ... the routine simplimit. simplimit has a lot of special code
build in to handle the different functions and calls an appropriate
subroutine. All this code could be replaced to look up a simplim%
function. I think this part of limit would be faster and more readable
with this mechanism.
> (%i1) :lisp(trace simplim%signum);
>
> simplim%signum isn't called (but it would be OK if it did)
>
> (%i1) limit(signum(x),x,inf);
> (%o1) 1
> simplim%signum is called:
>
> (%i2) limit(signum(x + a),x,inf);
> 0> Calling (SIMPLIM%SIGNUM ((%SIGNUM SIMP) ((MPLUS SIMP) $A $X)) $X $INF)
> <0 SIMPLIM%SIGNUM returned 1
> (%o2) 1
The reason for this behavior is an unnecessary (efficiency) hack in the
routine simplimit. At first simplimit tries to get a value for the
function and calls the simplifier via simplimsubst. Therefore, if
simplimsubst succeeds, the simplim%function is bypassed.
If the call of simplimsubst does not succeed, the algorithm goes on and
looks if the function has a special subroutine. At last the simplim%
function is looked up.
This is the code which tries to get a value at the beginning of
simplimit:
((and (not (infinityp val))
(not (amongl '(%sin %cos %atanh %cosh %sinh %tanh mfactorial %log)
exp))
(not (inf-typep exp))
(simplimsubst val exp)))
I think it is much more direct to call immediately a special simplim%
function to get the desired value of the function.
Dieter Kaiser