On Sun, Oct 16, 2011 at 18:05, Panagiotis Papasotiriou <
p.j.papasot at gmail.com> wrote:
> ...either mode_declaring floats as "any" doesn't help at all...
Correct, declaring an object as "any" means that Maxima must handle the
general case of symbolic arithmetic (see below). To get fast numerical
arithmetic, you need to operate on floats.
General symbolic arithmetic is much slower than numerical arithmetic. See
the trace below to see how Maxima simplifies 1+2 => 3
-s
f(x):=(modedeclare(x,any),x+1)$
translate(f)$
f(z) => z+1
g(x):=(modedeclare(x,float),x+1)$
translate(g)$
g(z) =>
Maxima encountered a Lisp error:
Error in + [or a callee]: $%PI is not of type NUMBER.
----------------------------
1> (SIMPLIFYA ((MPLUS) 1 2) NIL)
2> (SIMPLUS ((MPLUS) 1 2) 1 NIL)
3> (SIMPLIFYA 1 NIL)
<3 (SIMPLIFYA 1)
3> (PLS 1 NIL)
4> (MNUMP 1)
<4 (MNUMP T)
<3 (PLS ((MPLUS) 1))
3> (SIMPLIFYA 2 NIL)
<3 (SIMPLIFYA 2)
3> (PLS 2 ((MPLUS) 1))
4> (MNUMP 2)
<4 (MNUMP T)
4> (MNUMP 1)
<4 (MNUMP T)
4> (ADDK 1 2)
<4 (ADDK 3)
<3 (PLS ((MPLUS) 3))
3> (TESTP ((MPLUS) 3))
<3 (TESTP 3)
3> (EQTEST 3 ((MPLUS) 1 2))
<3 (EQTEST 3)
<2 (SIMPLUS 3)
<1 (SIMPLIFYA 3)