[sage-devel] presentation about Maxima at Sage developer days
Subject: [sage-devel] presentation about Maxima at Sage developer days
From: Richard Fateman
Date: Wed, 18 Jun 2008 12:04:44 -0700
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of Ondrej Certik
> Sent: Wednesday, June 18, 2008 10:10 AM
....
>
> I know you once written to the SymPy mailinglist asking us to rather
> join (or use) Maxima [1], instead of reinventing the wheel. Well, Sage
> does exactly what you wanted, i.e. using maxima from Python, instead
> of reinventing the wheel. But lisp is just too difficult for me (and
> all other people I personally know) to fix. The other reason is that I
> think lisp is dead.
>
> Compare this:
>
> http://maxima.cvs.sourceforge.net/maxima/maxima/src/limit.lisp
> ?revision=1.53&view=markup
>
> to this:
>
> http://hg.sympy.org/sympy/file/ccebd03423df/sympy/series/gruntz.py
>
> it has more or less the same functionality now.
I truly doubt that. 500 lines of python and 2700 lines of lisp?
I think that someone familiar with both languages would take it pretty much
for granted that 500 lines of python can be transcribed into about 500 lines
of lisp or so, and would be about as easy to read.
I note that lines 117 to 156 in the python code are for making and printing
trees. Compare these to the corresponding programs in Lisp. (read x)
(pprint x). Much easier to read in Lisp, I think.
See line 159
def compare(a,b,x):
159 """Returns "<" if a<b, "=" for a==b, ">" for a>b"""
160 c = limitinf(log(a)/log(b), x)
161 if c == 0:
162 return "<"
163 elif c in [oo,-oo]:
164 return ">"
165 else:
166 return "="
in lisp, it would be something like this.
(defun compare(a b x)
(let ((c (limitinf (/ (log a) (log b)) x)))
(if (= c 0) '<
(if (member c, '(inf minf)) '> '=))))
in python we have this..
if e.is_Rational or e.is_Real:
272 if e == 0:
273 return 0
274 elif e.evalf() > 0:
275 return 1
276 else:
277 return -1
278 elif not e.has(x):
279 f= e.evalf()
280 if f > 0:
281 return 1
282 else:
283 return -1
which in lisp would be, I think..
(if (numberp e)(signum e)(signum (evalf e))
So maybe the Gruntz algorithm in Lisp would be 200 lines of code.
The 2700 lines of lisp in the Maxima limit program may therefore reflect two
differences.
1. Gruntz' algorithm is not used, and the Maxima limit program uses various
heuristics. So it might not do as much as the Gruntz algorithm.
2. The Maxima program accesses a database of assumptions made by the user
(or possibly other programs) so it might better than the Gruntz algorithm.
As for lisp being dead, it has seen lots of languages come and go.
See
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
where Python is ranked 7, after visual basic, php, ...; the trend over time
suggests Ruby as an up-and-comer..
Lisp is ranked 16, next to Pascal. You may be too young to remember Pascal,
popular in the 1970's.
also see newgroup comp.lang.lisp
> Which is more
> readable? I guess there are people who will find the lisp version more
> readable, but I and most people I know find the python version more
> readable/maintainable.
Since these two files are not the same program, I do not see how you can
compare them on readability.
>
>
> However, on a positive note, I think this game is not a game with a
> sum of 1, but rather it seems to me that all Sage, Maxima, SymPy and
> other packages are getting new users and developers. In the end, all I
> want is to get the job done and I think it's important to make sure
> all the packages talk to each other well, and also to try to find
> common grounds of cooperation, if possible.
Let me propose getting together a group of people to write a program, let's
call it Page,
for People's AmalGam of Editors, that would be a front end to all the text
editing programs, allowing them to communicate with each other. To improve
it, we will also take some programs of the 10,000 or so available on
Windows, and rewrite them in Python, which should make them only a little
slower.
There are many many more users of text than of mathematics, so it should be
far more useful than Sage. There is an additional advantage that to work on
Page, you don't need to know higher math. Oh, I forgot, to work on Sage
you don't need to know math either.
RJF :)
not cc'd to Sage developers, since sarcasm doesn't work there, and this
login name is not a member..