Bug in free-infp and free-epsilon-p



I think the implementation of the macros free-epsilonp and free-infp in
maxmac.lisp is wrong. The code works only for an atomic expression, but
not as expected for an arbitrary Maxima expression.

This is correct:

(%i4) :lisp (free-infp '$inf)
NIL

But this is wrong:

(%i4) :lisp (free-infp '((mplus) $inf))
T

This is the code:

(defmacro free-epsilonp (x)
  `(do ((one-eps infinitesimals (cdr one-eps)))
       ((null one-eps) t)
     (unless (free (car one-eps) ,x) (return ()))))

(defmacro free-infp (x)
  `(do ((one-inf infinities (cdr one-inf)))
       ((null one-inf) t)
     (unless (free (car one-inf) ,x) (return ()))))

Both macros call the function FREE, which is defined in simp.lisp, with
a wrong order of the arguments. That is the definition of FREE:

(defmfun free (expr var)
  ...

But the macros call like (free var expr).

Furthermore, I think it is not a good idea to call the function FREE.
FREE tests for equality with the function alike1. So FREE will work for
an arbitrary Maxima expression as an argument var. But the infinities
and infinitesimals are simple symbols. Therefore, a call to the function
AMONGL might be more useful. This is done in the macro INF-TYPEP too.

I think we have three possibilities:

1. 
Correct the macros:

(defmacro free-epsilonp (x)
  `(do ((one-eps infinitesimals (cdr one-eps)))
       ((null one-eps) t)
-->  (unless (free ,x (car one-eps)) (return ()))))

(defmacro free-infp (x)
  `(do ((one-inf infinities (cdr one-inf)))
       ((null one-inf) t)
-->  (unless (free ,x (car one-inf)) (return ()))))

2. 
Replacing the macros with a shorter and more efficient definition:

(defmacro free-epsilonp (x)
  `(not (amongl infinitesimals x)))

(defmacro free-infp (x)
  `(not (amongl infinities x)))

3. 
Cutting out the usage of the macros completely and inserting a function
call to AMONGL.

Both macros are used only in limit.lisp at a very few places in the
code. The testsuite does not trigger any error because of these bugs and
I have no example which will work better with these corrections. Perhaps
someone will find an example.

I have found the bugs, because I have searched for a function to test an
expression to be free of infinites or infinitesimals, but the macros did
not work as expected.

Dieter Kaiser