using CL complex numbers ... was Re: Failures in share_testsuite



On 5/7/10, Richard Fateman <fateman at cs.berkeley.edu> wrote:

> It has been my hope for some time that CL complex numbers and CL
> rational numbers will become standard in Maxima.

Maxima is already fairly comfortable with CL rationals.
They don't act the same as Maxima rationals but at least Maxima
seems to treat them appropriately. Only strangeness I see in the
cursory overview below is that ev(<CL rational>, numer) doesn't
return a float. CL rationals aren't displayed the same as Maxima
rationals; I don't know if that's a bug.

(%i113) :lisp (defparameter $a (/ 17 11))

$A
(%i113) a;
(%o113)                              17/11
(%i114) a + 1;
(%o114)                              28/11
(%i115) expand ((a + x)^3);
                      3          2
(%o115)              x  + 51/11 x  + 867/121 x + 4913/1331
(%i116) solve (%, x);
                                         17
(%o116)                           [x = - --]
                                         11
(%i117) rhs (first (%)) + a;
(%o117)                                0
(%i118) is (17/11 = a);
(%o118)                              false
(%i119) is (equal (17/11, a));
(%o119)                              true
(%i120) a, numer;
(%o120)                              17/11
(%i121) 17/11, numer;
(%o121)                        1.545454545454545
(%i122) float (a);
(%o122)                        1.545454545454545


On the other hand Maxima doesn't like CL complex numbers.
A few things work but mostly not. Not sure how much effort it would
be to fix it up.

(%i1) :lisp (defparameter $b #C(1 1))

$B
(%i1) b;

Maxima encountered a Lisp error:

 Error in PROGN [or a callee]: Bind stack overflow.

Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.
(%i2) b + 1 $

(%i3) :lisp $%

#C(2 1)
(%i3) b + x $

(%i4) :lisp $%

((MPLUS SIMP) #C(1 1) $X)
(%i4) expand ((b + x)^3) $

(%i5) :lisp $%

((MPLUS . #0=(SIMP)) #C(-2 2) (#1=(MTIMES SIMP) #C(0 6) $X)
 (#1# #C(3 3) (#2=(MEXPT . #0#) $X 2)) (#2# $X 3))
(%i5) solve (%o4, x) $

Maxima encountered a Lisp error:

 Error in MSIZE-PREFIX [or a callee]: Bind stack overflow.

Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.
(%i6) sin (b) $

(%i7) float (sin (b)) $

Maxima encountered a Lisp error:

 Error in MACSYMA-TOP-LEVEL [or a callee]: #C(1 1) is not of type (OR
                                                                   RATIONAL
                                                                   LISP:FLOAT).

Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.
(%i8) float (b) $

Maxima encountered a Lisp error:

 Error in MACSYMA-TOP-LEVEL [or a callee]: #C(1 1) is not of type (OR
                                                                   RATIONAL
                                                                   LISP:FLOAT).

Automatically continuing.
To enable the Lisp debugger set *debugger-hook* to nil.
(%i9)


FWIW

Robert Dodier