maxima written in maxima



Conjecture:  Suppose you rewrote large chunks of Maxima in Maxima.  By the 
 time you finished 
(1) fixing bugs and inefficiencies in the translator, (2) writing 
Maxima-level interfaces to many 
functions in  the Maxima core and to other common Lisp functions, you'd be 
sufficiently 
competent in Lisp to  have done all your work in Lisp in the first place.

I had many reasons for rewriting specfun in Lisp (now orthopoly);  some 
were good 
some neutral (insomnia,  long, dark, cold Nebraska winters, etc).   But

(1)  Yes, the mathematical parts of orthopoly could be expressed more 
compactly in
infix notation; however  (a) surprisingly little of orthopoly is 
mathematical stuff 
(b) I generated most (probably all) of the lengthy mathematical  prefix 
expressions 
in orthopoly automatically (via ?print and other tricks).

(2) Floating point complex number arithmetic is slow in Maxima;  I think 
it would
be  difficult to make it fast.  By rewriting in Lisp, orthopoly is able to 
use Lisp complex 
numbers.

(3) Maxima arrays are unpleasant to use (that's my opinion) and 
inefficient (I believe, but I haven't
tried any tests so I could be wrong) -- orthopoly uses Lisp arrays in a 
few places.

(4) If you know how to do something in Maxima, but not in Lisp, you can 
always try
translating a tiny piece of Maxima code to give you a clue how to do it in 
Lisp.

(5) Is it possible to write a  function that simplifies instead of 
evaluates in Maxima? 
Maybe it is, but I don't know how  --- it's fairly straightforward to do 
so in Lisp. 
For example, can you write a function that is equivalent to 

(C18) qqq(x) := if atom(x) then 42 else funmake(qqq,[x]);
(D18)         qqq(x) := IF ATOM(x) THEN 42 ELSE FUNMAKE(qqq, [x])
(C19) qqq(4);
(D19)                                 42
(C20) qqq(a+b);
(D20)                             qqq(b + a)
(C21) subst(a=0,%);
(D21)                               qqq(b)
(C22) ev(%);
(D22)                                 42

that doesn't need the extra evaluation in (c22)? 

(6) As it is now, the Maxima to Lisp translator has too many bugs to make 
it a reliable 
way to write good code.  Try translating a tellsimpafter; for example

----- start of file------------------
matchdeclare(x,true);
tellsimpafter(f(x),0);

--------------------------------------

I'm guessing the translated code would work for some ancient Lisp -- but 
it
no longer works.

Barton