Re: Re: Simplifying If expressions
- To: mathgroup at smc.vnet.net
- Subject: [mg103039] Re: [mg103026] Re: Simplifying If expressions
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Fri, 4 Sep 2009 07:02:22 -0400 (EDT)
- Reply-to: hanlonr at cox.net
There is no comparison required but instead a determination that either possible alternative results in zero hence the statement is equivalent to zero. Bob Hanlon ---- Bill Rowe <wjrowe at sbcglobal.net> wrote: ============= On 9/3/09 at 5:41 AM, pfalloon at gmail.com (pfalloon) wrote: >I don't know about anyone else, but I was surprised and troubled to >see the following result (as pointed out by others in this thread): >In[3]:= If[x==0,x,0] // FullSimplify Out[3]= 0 >To me this seems simply incorrect. For example, what about the >following cases: >In[5]:= With[{x=0.}, If[x==0,x,0]] Out[5]= 0. In this case, you compare a machine precision value (which is representable in binary) to an exact value. Mathematica finds the two value equal as described in the documentation >In[11]:= With[{x=1`20-1}, If[x==0,x,0]] Out[11]= 0.*10^-20 Here, you compare an arbitrary precision value with an exact value that clearly differs. Mathematica recognizes this and returns the arbitrary precision value. Again, this works as documented for equa. >Is this intentional? Yes. What did surprise me was having If[x == 0., x, 0]//FullSimplify evaluate when x does not have an assigned value. To me, it seems wrong for Mathematica to evaluate this with no assigned value for x since in that case there is no basis for comparison.