# [Maxima] Program stack overflow defining infix operator

Richard Hennessy rich.hennessy at verizon.net
Sat Aug 8 15:29:30 CDT 2009

```It is easy to put tellsimp rules on these functions too and get correct results but I guess there are better ways.

try

(%i1) matchdeclare([aa,bb,cc,dd,nn], true);
(out1)                                                              done
(%i2) tellsimp(%if(aa,bb,cc)+%if(aa,dd,nn), %if(aa,bb+dd,cc+nn));
tellsimp: warning: putting rules on '+' or '*' is inefficient, and may not work.
(out2)                                                       [+rule1, simplus]
(%i3) remove([aa,bb,cc,dd,nn], matchdeclare);
(out3)                                                              done
(%i4) %if(x>1,43,-43)+%if(x>1,-43,43);
(out4)                                                               0

(%i9) %if(x>1,45,-4)+%if(x>1,-34,65);
(out9)                                                     %if(x - 1 > 0, 11, 61)
(%i10) %if(abs(x)>3,5,7)+%if(abs(x)>4,3,4);
(out10)                   %if((x - 3 > 0) %or (- (x + 3) > 0), 5, 7) + %if((x - 4 > 0) %or (- (x + 4) > 0), 3, 4)

----- Original Message -----
From: "Barton Willis" <willisb at unk.edu>
To: "Robert Dodier" <robert.dodier at gmail.com>
Cc: <maxima at math.utexas.edu>
Sent: Friday, August 07, 2009 11:06 AM
Subject: Re: [Maxima] Program stack overflow defining infix operator

The file to_poly_solve_extra.lisp has simplifying versions
of and, or, and if (%and, %or, and %if). Some of these functions
include a scheme for simplifying inequalities as well. Maybe
these functions could be a start for standard logical connectives.

Barton

-----maxima-bounces at math.utexas.edu wrote: -----

It turns out the Boolean functions have a nonstandard evaluation
scheme. In general Maxima has a 1-time evaluaton policy,
but functions can evaluate their arguments as much they want.
Re-evaluation triggers the stack overflow here.

At present the Boolean functions MAND, MOR, MNOT are
functions which quote their arguments (DEFMSPEC), then they
explicitly call MEVAL. (This situation has existed since before
I arrived on the scene.) It would be better to do away with the
DEFMSPEC and MEVAL and make them simplifying functions
instead. That would avoid this bug, and make the Boolean
functions more like other, mathematical functions in Maxima.

I'll put it on my to-do list, unless someone wants to talk me
out of it. Someone else could do it too, I won't complain.

best

Robert Dodier
_______________________________________________

_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima

```