Re: Unconventional Max[] behavior
- To: mathgroup at smc.vnet.net
- Subject: [mg28095] Re: [mg28048] Unconventional Max[] behavior
- From: Ralph Benzinger <mma-l at endlos.net>
- Date: Fri, 30 Mar 2001 04:12:50 -0500 (EST)
- References: <200103290824.DAA03053@smc.vnet.net> <B6E8F603.BC12%andrzej@platon.c.u-tokyo.ac.jp>
- Sender: owner-wri-mathgroup at wolfram.com
On March 29, you wrote: > Note that it is quite easy to modify Simplify in such a way that > it will work with Max and symbolic expressions, e.g.: > > In[1]:= > Unprotect[Simplify]; > Simplify[Max[a___,x_,b___,y_,c___],assum_:{}]/;Simplify[x>y,assum]:=Simplify > [Max[a,x,b,c],assum]; > Simplify[Max[a___,x_,b___,y_,c___],assum_:{}]/;Simplify[x<y,assum]:=Simplify > [Max[a,b,y,c],assum]; > Protect[Simplify]; > {Simplify}; Thanks, Andrzej, for this suggestion; I like it a lot. It never occurred to me to use Simplify in a Condition, but then -- viewing Mathematica as a programming language -- I'm not quite used to the distinction between evaluation and simplification anyway. Note, by the way, that In[1]:= Simplify[Max[a+3,a^2+a+3,a],a>0] Out[1]= 3 + a + a^2 even without your additional rules. Simplify is quite smart after all! > The answer to the second question is similar, that is, you have > ot modify Simplify in the above manner or define your own > version. Yes, but since my main research involves theorem provers, I traditionally shy away from Unprotecting things. :-) I thought of writing a wrapper function, but the one I'd propose for above example, i.e. maxSimplify[Max[a___, x_, b___, y_, c___], assum_:{}] /; maxSimplify[x > y, assum] := maxSimplify[Max[a, x, b, c], assum]; maxSimplify[x_,assum_:{}] := Simplify[x,assum] probably breaks down for cases where Simplification yields a Max term that only maxSimplify can handle (I cannot come up with such an example right now but I'm rather sure that one must exist). Is there a more proper way to write a wrapper function for Simplify -- or am I just too paranoid? Ralph -- Ralph Benzinger "This is my theory, it is mine, I own it, Cornell University and what it is, too." -- Ann Elk (Mrs.)
- References:
- Unconventional Max[] behavior
- From: Ralph Benzinger <mma-l@endlos.net>
- Unconventional Max[] behavior