compiling maxima code vs native lisp code



Regarding speed, the most important consideration in my mind is the
proportion of the processing that is done in subroutines or explicitly in
your code. 

For example, writing a loop
  for i:10 thru 100 do print(factor(x^i+i*x+1))
 
will spend most of its time in factor, so compiling it or writing it in lisp
would not be worthwhile.

However, 
   sum:0,
   for i:10 thru 100 do sum:sum+i

Will spend most of its time in the code you see in front of you: doing
arithmetic.


And
  sum:0,
 for i:10 thru 100 do sum:sum+x^i  

Will spend most of the time in the simplifier.

If you want to speed up this last loop, you can do so by initializing
sum:rat(0)

And translating to lisp is pretty much irrelevant.

RJF

> -----Original Message-----
> From: maxima-bounces at math.utexas.edu 
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of Barton Willis
> Sent: Sunday, April 15, 2007 12:54 PM
> To: sen1 at math.msu.edu
> Cc: maxima at math.utexas.edu; maxima-bounces at math.utexas.edu
> Subject: Re: [Maxima] compiling maxima code vs native lisp code
> 
> If your code does a great deal of complex double float
> arithmetic, you should be able to gain a great deal of
> speed by coding in CL instead of Maxima. Outside of this
> consideration, it's not so easy to say. With CL, you get
> a more comfortable programming environment (better tools
> for editing, lexical scope instead of dynamic, ...). Also,
> compiled CL should handle recursively defined functions
> more efficiently than Maxima (if you are careful about it). 
> But to program effectively in CL, you may have to learn
> quite a bit about the Maxima source code.  The only way
> to do that, is to read the source. The Maxima source is
> poorly commented, and it is often difficult to understand.
> 
> maxima-bounces at math.utexas.edu wrote on 04/15/2007 02:01:00 PM:
> 
> > Hello,
> >   I am seeking an opinion in regard to developing software 
> for maxima
> >   for the purpose of execution speed.
> > 
> > Is it better to develop code in maxima, and then compile it, via
> > compile_file, or to simply write the lisp code itself and 
> load it at run
> > time?
> > 
> > TIA,
> >   -sen
> > 
> > 
> > 
> --------------------------------------------------------------
> -------------
> >   | Sheldon E. Newhouse            |    e-mail: 
> sen1 at math.msu.edu    |
> >   | Mathematics Department         |                      |
> >   | Michigan State University      | telephone: 517-355-9684    |
> >   | E. Lansing, MI 48824-1027 USA  |       FAX: 517-432-1562    |
> > 
> --------------------------------------------------------------
> -------------
> > _______________________________________________
> > Maxima mailing list
> > Maxima at math.utexas.edu
> > http://www.math.utexas.edu/mailman/listinfo/maxima
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>