Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: Maple unapply
Posted:
Dec 3, 1996 9:02 AM


Andre Poenitz (poenitz@mathematik.tuchemnitz.de) wrote: : Len Evens (len@schur.math.nwu.edu) wrote: :  I realize that squaring the indentity function is the same as the :  function described by :  :  x > x^2 :  :  but is there any special reason Maple does it this way? Is there :  some way to get it to do exactly the above?
It is actually described in the docs. Maple thinks that all functions belong to a commutative ring (like C([0,1])). Problem is if the function doesn't. (Try the same for a matrixvalued function!)
: I is sold as a feature ;) It would be wonderful if Maple did some : 'real' simplification on procedures ( (x>x)*(y>y) to (x>x)^2 : or (x>x^2) for that matter...), but the current behaviour is more : than rudimentary in this respect.
You may also want to try x > x^2+1.
: The annoying fact is that you can't rely on : 'type(unapply(...,...),procedure) is true'.
: So far I have found no way to convince Maple that I prefer the : x>x^2 notation. Maybe I am just lacking some insight.
Some weeks ago, I posted a remark similar to Len's (Andre, you remember?).
The problem is that a number of Maple functions rely on this odd behavior, like D. Thus I found it most convenient to rewrite the unapply procedure as dounapply (you may want to prefer the name really_unapply  but that's too long):
 >dounapply := proc(expr) local vars; vars := op(2..nargs,[args]); if not type([vars],list(name)) or nops([vars]) <> nops({x}) then ERROR(`variables must be unique and of type name`) fi; RETURN(subs(_b=expr,_x=(vars), proc(_x) options operator, arrow; _b end)); end:  > dounapply(x^2,x);
2 x > x  > type(",procedure);
true 
dounapply should behave exactly like unapply, except in the mentioned respect of course. Please mail me about any bugs.
Best wishes,
Dirk
 Dirk Alboth, Mathematics Dept., Paderborn University 33095 Paderborn, Germany



