> As far as I am concerned, this is the problem:
> There is no clear interface between the maxima math engine,
> and the maxima parser.
The interface between the parser and the math engine is actually quite
clean and simple. The only subtlety here is the parse-time-substitution
syntax ('').
Where things get complicated is the interaction among the evaluator, the
simplifier, and the evaluation/simplification context. You ask, for
example, how to "execute" ((mplus) 1 2). But in Maxima, calculating the
sum of 1 and 2 is just like calculating the sum of x and x = ((mtimes) 2
$x), that is, it is a matter of *simplification*, not evaluation.
Consider:
1 + 2 => 3 (evaluation and simplification)
'(1+2) => 3 (simplification but no evaluation)
simp:false$ 1+2 => 1 + 2 (evaluation but no simplification)
simp:false$ '(1+2) => 1 + 2 (neither)
x: 1234$
x + x + 1 => 2469 (evaluation and simplification)
'(x+x+1) => 2*x+1 (simplification but no evaluation)
simp:false$ x+x+1 => 1234 + 1234 + 1 (evaluation but no
simplification)
simp:false$ '(x+x+1) => x + x + 1 (neither)
At the Lisp level, if you want to add two symbolic expressions, you call
the ADD function:
(ADD 'x 2) => ((mplus simp) 2 x)
This depends on the *Lisp* evaluator, but the Maxima simplifier....
Your second example asks about MSET. Sure enough, MEVAL'ing ((mset) $x
1) will set the (existing or new) global variable $x to 1. Simplifying
it will not:
x : x + 2 + 3$ x => x + 5
kill(x)$
'(x: x + 2 + 3)$ x => x (i.e. x has not been modified)
simp:false$ x : x + 2 + 3$ x => x + 2 + 3
kill(x)$
simp:false$ '(x : x + 2 + 3)$ x => x (no modification)
The other thing that happens at the top level of the Maxima interaction
loop (read-eval-print loop) is that the Asksign database is reset:
(c1) [asksign(x),asksign(x)]
Is x positive, negative, or zero?
pos;
(d1) [pos, pos] (note that it reuses the first answer)
(c2) asksign(x);
Is x positive, negative, or zero? (note that it has forgotten the
previous answer)
Does this answer your question?
-s