Subject: Q: replace a function with simplifying function
From: Barton Willis
Date: Sun, 2 Oct 2005 06:50:06 -0500
How can I replace a Maxima function, defined using defmfun,
with a simplifying version of the function? Specifically,
I'd like to replace 'max' with a simplifying function. I
could remove the definition of 'max' from compar.lisp
and re-build, but I was looking for a quick temporary method.
For now, I named my 'max' function 'xmax.' A demo:
(%i6) load("new-max-min")$
(%i7) xmax(x,-x);
(%o7) abs(x)
(%i8) max(x,-x);
(%o8) MAX(x,-x)
The function 'xmax' can remove expressions that are in the middle:
(%i9) xmax(x,2*x,3*x);
(%o9) XMAX(3*x,x)
(%i10) max(x,2*x,3*x);
(%o10) MAX(3*x,2*x,x)
Looking for middle terms is spendy -- it can be be turned off:
(%i13) put(trylevel,1,maxmin)$
(%i14) xmax(x,2*x,3*x);
(%o14) XMAX(3*x,2*x,x)
The function 'xmax' can handle long argument lists:
(%i15) x : makelist(i,i,1,10000)$
(%i16) apply('xmax,x);
(%o16) 10000
(%i17) apply('max,x);
Maxima encountered a Lisp error:
This was done using GCL -- your Lisp may vary.
Barton