[Maxima] Functions and simplification WAS: Fully simplifiying Exp function
macrakis at alum.mit.edu
Tue Jan 6 11:09:47 CST 2009
I don't think our rules for when to call simplification etc. are
documented anywhere. Here's a first try.
1) All routines callable from the Maxima level (namely, all $xxx
functions) should assume that their arguments are simplified but may
return unsimplified results. MEVAL takes care of simplifying
arguments and simplifying results as necessary. When constructing
algebraic expressions, they should preferably use add, mul, etc. which
take care of simplification; or they can construct algebraic
expressions *without* simp flags and call simplifya. They should
*not* create expressions with a SIMP flag explicitly except for
constants (e.g. ((mtimes simp) 2 $%pi)).
2) Within Lisp code, in general functions can assume that their
arguments are simplified and should return simplified results. That
is the best convention, but some existing packages may have other
3) Functions and routines should never explicitly check $SIMP and
DOSIMP -- those flags should be handled only by the top-level
simplifying functions. Functions and routines should not call
resimplify or ssimplifya except in very special circumstances.
4) Simplifying functions (simp-%xxx) work differently from other
routines. They always take three arguments, conventionally called
(form vestigial simp-flag) or the like. The first argument is the
full form ((%xxx)...) to be simplified. The second argument is
ignored. The third argument, if T, means that the *arguments* of form
are already simplified; if NIL, means that cannot be assumed to be
simplified, and (simplifya arg nil) should be called on them.
Arguments to %xxx may also be special forms (CRE etc.). But you don't
need to know all those details: simply call (simpcheck <arg>
simp-flag) on each argument before doing anything else.
5) In general, Maxima and Lisp code *cannot* be assumed to work
correctly when SIMP = NIL.
More information about the Maxima