What we get from (0.0*x), (0.0^x) and similar stuff
- To: mathgroup at smc.vnet.net
- Subject: [mg58664] What we get from (0.0*x), (0.0^x) and similar stuff
- From: ted.ersek at tqci.net
- Date: Wed, 13 Jul 2005 03:28:56 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
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}
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}
We can use the definitions below to ensure the input above returns {0. ,
1, 0.} and some will consider this a nice improvement.
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