On Tue, Nov 24, 2009 at 1:55 PM, Dieter Kaiser <drdieterkaiser at web.de> wrote:
> One of the next bugs I would like to close is the bug ID: 2031312 "take
> macro".
>
> I think it is more correct to cut out the shortcuts to the simplifier
> from the macro TAKE, e.g. the calls to simp-%sin, simp-%cos, or simpabs.
> Because of these shortcuts the general simplification rules of the
> simplifier will not work as expected.
I agree.
> Because there are some discussions in the thread of the bug report I try
> to summarize some aspects:
>
> 1. Both the macro TAKE and the function SIMPLIFY are shortcuts for a call
> of the simplifier, that is (simplifya expr simpflag):
>
> (take '(op) args) ? ? ? ? ? ? --> (simplifya (list '(op) args) t)
> (simplify (list '(op) args)) ?--> (simplifya (list '(op) args) nil)
>
> Here expr is the list (list '(op) args).
>
> The call with a simpflag NIL is more general and works for simplified or
> unsimplified arguments of an expression. The macro TAKE is a bit more
> efficient, when it is known that the arguments are already simplified.
The general rule in Maxima is that functions should return simplified
results. Therefore simpflag=T should be the default, as it is with
add/mul/div/etc.
> Unfortunately, the names TAKE and SIMPLIFY do not reflect this small
> difference. I have no idea what names would be the best for both.
The consistent name would be take* for the simpflag=NIL case, just
like add*/mul*/etc.
> Furthermore, we have a macro definition for TAKE and a function
> definition for SIMPLIFY.
Simplify and take in theory have different purposes. Simplify
resimplifies a whole expression; take is for constructing an
expression.
I suppose simplify is useful in cases like (simplify '((mplus) -1
((expt) ((%sin) x) 2))) where the author wants to write a literal
Maxima expression, but make sure that any custom simplifications apply
to it. Personally, in that case, I'd recommend instead (add -1 (power
(take '%sin x) 2)).
> Remark: I think TAKE and SIMPLIFY are shortcuts which help to make the
> code more readable.
>
> 2.
>
> The function RESIMPLIFY calls the simplifier too, but sets the flag
> DOSIMP to T. Therefore, simpflags of an expression are ignored. The
> expression is again simplified completely.
> RESIMPLIFY is called by the function $expand. Therefore a call from the
> user like expand(expr,0,0) resimplifies the expression.
>
> The function RESIMPLIFY has a duplicate SSIMPLIFY. This duplicate is
> only used at a few places and should be replaced by RESIMPLIFY.
>
> Remark: Because RESIMPLIFY ignores the simplification work which has
> been done already, this function has to be used very carefully.
Agreed. resimplify is a very special-purpose function, and is almost
never the right thing. It should only be used when you know you have
a simplified expression which has been simplified in one environment
(assume's, simplification rules, simplification flags) and which you
want to resimplify in a different environment. It should never be
used just for simple simplification.
> At last, I think we should start and cut out the shortcuts to the
> simplifier from the macro TAKE.
Agreed.
>
> Dieter Kaiser
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>