# [Maxima] mathematic to maxima translation

John Lapeyre pdl at johnlapeyre.com
Tue Sep 23 14:42:42 CDT 2008

```> the ordinary syntax of ordinary expressions is
> easy. Solving these problems does not lead to an easy
> solution to the tricky parts of Mathematica syntax. Maybe
> all you need is the simple part.

Some things should be easy, but I still find it difficult or
time consuming to implement them. I don't want to work on
harder stuff until the most common easy things are done.  I
hope the framework _allows_ the harder things to be done,
even if it doesn't provide a solution.

> Tricky: the pattern matching notations, the use of operators that occur
> within other operators, like =,==,===, /, //, /. , _ __ ___ and the postfix
> stuff.
>
> For example x+y/.y->3   produces 3+x.
> x+3/.3->y   produces  10.+x->y

I'll have to look into that. It doesn't look easy!

> I think that your translation of ++ by doing an addition and a subtraction
> doubtful.
>
> x++ could be block([temp123:x],x:x+1,temp123).  You need to generate a name
> not used by anyone else for the temp.  ?gensym()  will do it.
> you may need to learn to use macros and buildq, for example:
>
> incf(x):=buildq([temp:?gensym()],block([temp:x],x:x+1,temp));
>
> which produces the appropriate program.

The solution I have does give the correct result in at least
some cases, eg:

a=1; 1 + a++;

vs.

a=1; 1 + ++a;

I thought about using a temporary variable and gensym, but I didn't
know how to do it. Thanks for the tip.

I need to spend more time learning Maxima macros. ( Additional documentation
would be useful.)

> In fact, you should consider the approach of macro
> expansion instead.  That is, you should take a Mma program
> and translate it into a Maxima program.  What you are
> doing is taking a Mma program and EXECUTING it in Maxima,
> sortof.

This sounds interesting. But, I'm not sure I understand it yet.