Maxima vs Axiom



Stavros Macrakis wrote:
> Michel,
>
> You can probably redefine := as define, but then most existing Maxima code
> (including 'share' packages) will no longer load correctly -- most existing
> function definitions will have to be written as
>
>           foo(...) := '( ... )
>
> That doesn't seem like an improvement.
>
> Apparently in your work and in Daniel's, the case of defining a function
> dynamically is common.  But in most work with Maxima, it is a rare and
> unusual case.  Why would you want to make it easy to handle the rare case
> at the cost of making the common case clumsy?

I am not advocating modifying the definition of := (except eventually in
private work). This being said, i have checked that the "function" concept in
maxima and in maple work exactly the same, so one can safely say this is the
standard way of doing things. Below i am doing the same stuff first in maxima,
then in maple, and get exactly the same sort of result:


lilas% maxima
(%i1) f(x):=x^2$

(%i2) g(x):=diff(f(x),x)$

(%i3) g;
(%o3)                                  g
(%i4) g(x);
(%o4)                                 2 x
(%i5) g(2);

diff: second argument must be a variable; found 2
#0: g(x=2)
 -- an error. To debug this try: debugmode(true);


In maple functions can only be defined via the proc syntax as below:

niobe% maple
    |\^/|     Maple 9 (IBM INTEL LINUX)
._|\|   |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2003
 \  MAPLE  /  All rights reserved. Maple is a trademark of
 <____ ____>  Waterloo Maple Inc.
      |       Type ? for help.

> f:=proc(x) x^2 end proc;
                                          f := proc(x) x^2 end proc

> f;
                                                      f

> f(x);
                                                      2
                                                     x

> g:= proc (x) diff(f(x),x) end proc;
                                     g := proc(x) diff(f(x), x) end proc

> g(x);
                                                     2 x

> g(2);
Error, (in g) wrong number (or type) of parameters in function diff


I must say i find extremely puzzling to be able to require g(x) -> 2x but that
g(2) errors out, both in maxima and maple.

As far as documentation is concerned, in my opinion maple has a more explicit
and clear documentation for proc, let me quote:

Procedures have special evaluation rules (like tables) so that if the name f
has been assigned a procedure then:

  f evaluates to the name f;

  eval(f) yields the actual procedure structure;

  op(eval(f)) yields the sequence of eight operands mentioned above (any or
all of which may be null).

- A procedure assigned to f is invoked by using f(arguments). See parameters
for an explanation of parameter passing. The value of a procedure invocation
is the value of the last statement executed, or the value specified in a
return statement.

- Remember tables (option remember) should not be used for procedures that are
intended to accept mutable objects (e.g., rtable) as input, because Maple does
not detect that such an object has changed when retrieving values from
remember tables.

I think that procedures with option remember are the same thing as array
functions in maxima parlance.





-- 
Michel Talon