next up previous contents
Next: Other Assign forms Up: Implementation Previous: Formatting C Expressions

Conversion to Maple

A basic expression translator from Mathematica to Maple has been implemented. The MapleAssign command works slightly differently from the other Assign-related functions in that the rhs is maintained in unevaluated form. The following example illustrates how lists and matrices (lists of lists) of expressions can be converted.

In[4]:= MapleAssign[ z, {NSolve[x^7+x^5-x==0,x],
          Map[f,Sin[x^2] y CosIntegral[2]]}]

Out[4]//OutputForm=
z:=[fsolve(-x+x^5+x^7=0,x),map(f,y*Ci(2)*sin(x^2))];
In contrast, all other Assign functions output a sequence of statements, with lhs indices in correspondence with the shape of the list.

Most Mathematica operators are translated by MapleAssign without evaluation. However, it is convenient to allow some basic arithmetic operations to be performed during the conversion process. The operators Plus, Power and Times are evaluated during conversion. Consequently some numeric operations are performed.

In[5]:= MapleAssign[ intex, Integrate[Sin[x^2 + 1/3 - 2/11 ],x] ]

Out[5]//OutputForm=
intex:=int(sin(5/33 + x^2),x);
Some more complicated, but commonly used, functions have also been implemented.

In[6]:= MapleAssign[ diffex, D[AiryAi[1.] Sin[x y],{x,2},y] ]

Out[6]//OutputForm=
diffex := diff(diff(Ai(1.)*sin(x*y),x$2),y);
A few Maple library procedures have also been implemented. These must be read in using with(libname), before execution in Maple. Because of syntactical differences between the two languages, some decisions need to be made during conversion. In the following example the higher of the two truncation orders specified in Series, is passed to the Maple equivalent mtaylor.

In[7]:= MapleAssign[seriesex,Series[Sin[x y],{x,1,3},{y,2,2}]]

Out[7]//OutputForm=
seriesex := mtaylor(sin(x*y),[x=1,y=2],3);
Substitutions analogous to Mathematica's replacement rules can also be performed in Maple.

In[8]:= MapleAssign[y,f[g,h] /. {g->1,h->2}]

Out[8]//OutputForm=
y:=subs([g=1,h=2],f(g,h));
MapleAssign is a less complete implementation than the related Assign functions. It is useful for comparison purposes and cross-checking of results. While computer algebra systems contain bugs, it is far less likely that the same bug exists in two different systems. Almost all of the basic functions in Maple (those not utilising external libraries) have direct equivalents in Mathematica. These have been implemented. User-defined procedures and functions are not yet supported.

The command MapleAssign also illustrates the difference in syntax between Mathematica and Maple. The design of the programming languages and differences in the evaluation processes, make it questionable as to whether more extensive developments are worthwhile.


next up previous contents
Next: Other Assign forms Up: Implementation Previous: Formatting C Expressions

Jorge Romao
5/14/1998