Re: What we get from (0.0*x), (0.0^x) and similar stuff

*To*: mathgroup at smc.vnet.net*Subject*: [mg58757] Re: What we get from (0.0*x), (0.0^x) and similar stuff*From*: "David W. Cantrell" <DWCantrell at sigmaxi.org>*Date*: Sun, 17 Jul 2005 03:04:06 -0400 (EDT)*References*: <db2g2e$dh7$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

ted.ersek at tqci.net wrote: > Many users will see nothing wrong with what we get from the following: > > In[1]:= Clear[x,y]; > {x^0.0, x^0, 0*x*y} > > Out[2]= {1., 1, 0} In a sense, there is something wrong. These simplifications are what David Stoutemyer called "misdemeanors" in his article "Crimes and Misdemeanors in the Computer Algebra Trade", _Notices of the American Mathematical Society_ 38:7 (1991) 778-785. In case anyone doesn't see why simplifying, say, x^0 to 1 is a misdemeanor: In Mathematica, 0^0 is regarded as being Indeterminate. Thus, without knowing that x is nonzero, Mathematica should not bluntly simplify x^0 to 1. Rather, it would seem that, in Mathematica, x^0 should simplify to, say, If[x == 0, Indeterminate, 1]. But such a result is normally considered to be too cumbersome to be practical; the "misdemeanor" simplification is considered preferable. All CASs known to me make such simplifications. Perhaps it should be noted that many mathematicians (including me) consider x^0 = 1 always (in particular, even when x is zero). For them, simplifying x^0 to 1 is perfectly correct. [But I would still say that Mathematica's simplifying x^0 to 1 is a misdemeanor because Mathematica considers 0^0 to be Indeterminate.] IMO, simplifying x^0.0 to 1.0 is a substantially worse misdemeanor. Since the exponent is only close to 0, the result need not be close to 1 at all. > But the kernel does nothing to simplify the next input. I suppose this > is because the result is Indeterminate in the case of (0.0*Infinity), or > (0^0). So then why didn't the kernel account for that with the previous > example? > > In[3]:= {0.0*x*y,0^x,0.0^x} > > Out[3]= {0. x y, 0^x, 0.^x} I'm glad that 0.0*x*y was not simplified to 0.0. Since one of the factors is only close to 0, the product need not be close to 0 at all. (This is analogous to the case x^0.0 considered above. Why Mathematica chooses to simplify x^0.0 to 1.0, but not 0.0*x*y to 0.0, I don't know. That behavior seems inconsistent to me.) But 0^x and 0.0^x are very different from the previously considered cases. For example, 0^x is 0 if x is a positive real, but ComplexInfinity if x is a negative real. I would consider simplifying 0^x to 0 to be a "crime", not a mere "misdemeanor", if x might potentially be negative. > We can use the definitions below to ensure the input above returns {0. , > 1, 0.} and some will consider this a nice improvement. You meant to say {0., 0, 0.}, but I would not consider that an improvement. Indeed, I consider the latter two simplifications to be dangerous. Regards, David Cantrell > In[4]:= Unprotect[Times,Power]; > Times[0.0,__?(#=!=Indeterminate&&Head[#]=!=DirectedInfinity&)]=0.0; > Power[0, > _?((!NumericQ[#]||Positive[Re[#]])&&Head[#]=!=DirectedInfinity&)]=0; > Power[0.0, > _?((!NumericQ[#]||Positive[Re[#]])&&Head[#]=!=DirectedInfinity&)]=0.0; > > In[9]:= {0.0*x*y, 0^x, 0.0^x} > > Out[9]= {0., 0, 0.} > > After making the above definitions we still get Indeterminate or > ComplexInfinity whenever we should. See the next input as an example. > > In[10]:= {0*x*¥, 0*x*Indeterminate, 0^0, 0^Indeterminate, 0^(I-3)} > > Out[10]= {Indeterminate, Indeterminate, Indeterminate, Indeterminate, > ComplexInfinity} > > However some users might want to always acount for the possibity that we > might have (0*Infinity) or (0^0) and so prefer that the list below would > return itself. However, I think it isn't possible to do that because > since Mathematica Version 3 Times and Power use built-in definitions > before user definitions. Am I wrong? Can anyone change the outcome > below? > > In[11]:= Clear[Times,Power]; > {x^0.0,x^0,0*x*y} > > Out[11]= {1., 1, 0} > > -------- > Regards, > Ted Ersek

**Diagonalizing a non-Hermitian Matrix**

**Re: Modeling and Array Problem**

**What we get from (0.0*x), (0.0^x) and similar stuff**

**What we get from (0.0*x), (0.0^x) and similar stuff**