# [Maxima] the 'take' macro

Barton Willis willisb at unk.edu
Fri Apr 27 10:24:58 CDT 2007

The 'take' macro (defined in mopers.lisp) special cases
the operators mabs, %cos, and a few more. For these
cases, 'take' sends the expression directly to the
simplification function instead of going through
simplifya. I think this could cause bugs with tellsimp:

(%i1) tellsimp(abs(x),x)\$
(%i2) tellsimp(f(x),x)\$
(%i3) to_lisp();

The tellsimp rule *isn't* applied to mabs, but I think it
should be applied:

MAXIMA> (take '(mabs) '\$x)
((MABS SIMP) \$X)

The tellsimp rule *is* applied to \$f

MAXIMA> (take '(\$f) '\$x)
\$X

I know of no bugs that this might cause. I tried building Maxima using

(defmacro take (op &rest args &aux simplifier)
(if simplifier `(,simplifier (list ,operator . ,args) 1 t)
`(simplifya ((,op) , at args) t)))

but I got lots of errors. One test that failed with my code was rtest8 #5:

realroots(x^5-x-1,5.0e-6);
[x = 612003/524288]\$

ev(%[1],float);
x = 1.16730309\$  <-- test 5

Oh no! The expected answer looks like a single float. Maybe
it's something else that is causing trouble--Sourceforge
didn't allow me to update this morning. Doesn't the testsuite
try ratsimp? If so:

(%i13) [x = 612003/524288]\$
(%i14) ev(%[1],float);
(%o14) x=1.167303085327148
(%i15) %-(x = 1.16730309);
(%o15) 0=-4.67285143912477*10^-9
(%i16) ratsimp(%);
`rat' replaced -4.67285143912477E-9 by -1/214002095 =
-4.672851450356128E-9
(%o16) 0=-1/214002095

I'm not sure what's going on.

Barton