Re: Unconventional Max[] behavior
- To: mathgroup at smc.vnet.net
- Subject: [mg28085] Re: [mg28048] Unconventional Max[] behavior
- From: Andrzej Kozlowski <andrzej at platon.c.u-tokyo.ac.jp>
- Date: Fri, 30 Mar 2001 04:12:34 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
The first question: the behaviour you observed has little if anything to do with the inner workings of Max and is determined by the "inner workings" of Simplify. Or rather, it looks to me like a small omission in the inner workings of Simplify. I suspect, however, that is is not really important because, as you had originally assumed, Max and Min are really intended to deal with numeric quantities. Note that it is quite easy to modify Simplify in sucha 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}; With this modification we can apply Simplify to Max even with symbolic expressions, e.g.: In[10]:= Simplify[Max[2a+1,2a+2,2a+3]] Out[10]= 3 + 2 a In[11]:= Simplify[Max[a+3,a^2+a+3,a],a>0] Out[11]= 2 3 + a + a The problem with this approach is that it makes Simplify work much more slowly with expressions containing Max with symbolic parameters, which may be undesirable in some situations. So it may be be prefarable to define a new function (e.g. mySimplify or myMax) which would behave in the above way. The answer to the second question is similar, that is, you have ot modify Simplify in the above manner or define your own version. -- Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ on 3/29/01 9:24 AM, Ralph Benzinger at mma-l at endlos.net wrote: > Hello: > > For many years I've been under the impression that Max[] can deal with > numerical quantities only: > > In[1]:= > Max[a + 1, a + 2] > Out[1]= > Max[1 + a, 2 + a] > > I was quite surprised when some days ago I discovered by accident that > Max[] actually does simplify symbolic arguments when specifically told > to do so: > > In[2]:= > Max[a + 1, a + 2] // Simplify > Out[2]= > 2 + a > > But I was even more surprised when I tried to get a feel for the > capabilities of the function: > > In[3]:= > Max[2a + 1, 2a + 2] // Simplify > Out[3]= > Max[1 + 2 a, 2 + 2 a] > > Just WHY can Mathematica simplify [2] but not [3]? Does anybody > happen to know some details about the inner workings of the Max[] > function? > > A related question to my "discovery": Is there a standard way of > defining a "simplification" rather than an "evaluation" rule? For > example, if I have some function `foo' and I do _not_ want to include > the definition > > foo[a_] + foo[b_] ^:= foo[a+b] > > can I still have the rewrite rule > > foo[a_] + foo[b_] -> foo[a+b] > > applied automatically whenever I invoke Simplify[]? > > Regards, > Ralph