Re: Simplifying If expressions
- To: mathgroup at smc.vnet.net
- Subject: [mg103026] Re: Simplifying If expressions
- From: Bill Rowe <wjrowe at sbcglobal.net>
- Date: Fri, 4 Sep 2009 03:16:16 -0400 (EDT)
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.