Translating Mathematica to Maxima



I just want to add some 2 cents to this discussion of translators from
Maple or Mathematica to Maxima. Yes, indeed it is true that via that
solution one ends up inheriting a lot of code and from that po9int of
view things may look good on the short term ... but one thing that we
should remember is that a lot of progress is made on all fronts all the
time and a lot of that code is just plain BAD code. Let me give you a
clear example - try to integrate the function 


		(cos(x))^2 * exp(-x^2) 

from minus infinity to infinity, using for example Maple.
And then compare with the integral of

		((1 + cos(2*x))/2) * exp(-x^2)

in the same interval. The two functions are exactly the same, because of
the trivial trig equality, but Maple integrates the first to:
	
> integrate(((cos(x))^2) * exp(-x^2),x=-infinity..infinity);     
                                    1/2
                              1/2 Pi    exp(-1)

> integrate(((1 + cos(2*x))/2) * exp(-x^2),x=-infinity..infinity);

                              1/2         1/2
                        1/2 Pi    + 1/2 Pi    exp(-1)

which are, of course, different.

I reported this bug to Maple developers some 18 YEARS AGO! I still have
the original e-mail sent to them.... and they still have not fixed it
... this would never be the case in an Open Source environment.

Paulo Ney



-----Original Message-----
From: maxima-admin at www
[mailto:maxima-admin@www.ma.utexas.edu] On Behalf Of Richard Fateman
Sent: Friday, May 17, 2002 3:49 PM
To: James Amundson; maxima
Subject: Translating Mathematica to Maxima

Adding some to Jim's comments on FFI Corba etc...
I agree with his assessment,generally



I could provide a common lisp translator
from the Mathematica expression language to Maxima.
That is  Sin[x] would become sin(x)
          3x     would become 3*x
  etc.
There is no obvious counterpart to
    f[r[x_]+y_,s[z_]+w___]:= ....
in the maxima world.  So the trick would be
to have an alternative front end AND CORRESPONDING
BACK END in which the evaluation
is done by pattern matching in the Mathematica way.

Note that producing the corresponding data structures
in maxima from mathematica is in some sense trivial
if you write out all your commands in FullFormat in
Mathematica.  Then 3x is Times[3,x]  which is
trivially converted to maxima.

This is doable, especially since I also wrote a
pattern matcher.  But kind of unpleasant.

If all you want is mathematica's version of the common
intersection, e.g. +*-sin/cos , that's not bad at all.

Similarly, if you really want Maple, it would not
be hard to write a Maple parser, but to make it all
work you would have to write a Maple kernel.  This
could be done, I think, with a lot less work in Lisp,
than it was done originally.  There would be no need
to write a memory allocation system or bignums.
I have thought about this some, and the big advantage
that you'd have if you could just snarf up all the
Maple source code that you can print out from a
copy of Maple.  (I don't know what fair use of this
constitutes, but it is obvious that redistribution
to people who don't also have a Maple license would
be questionable!)

I think that one could also communicate via Java
tools, but I've never tried it.

I think the difficulty of doing FFI by hand is
overestimated.  If you have a few, you can do each one.
If you have a lot, then maybe you should have one new
C function that is the only one in the FFI interface and in a
Lisp-system independent fashion does
   interfacefun("string-name-of-function", "argument-count", 
"array-of-args")

There are issues of return values and changed reference
parameters that may need to be addressed.

RJF




_______________________________________________
Maxima mailing list
Maxima@www.math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima