MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Simplifying If expressions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103000] Re: [mg102969] Re: Simplifying If expressions
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Thu, 3 Sep 2009 19:54:36 -0400 (EDT)
  • References: <287030.1251791777166.JavaMail.root@n11> <h7l91h$3cj$1@smc.vnet.net> <200909030941.FAA20932@smc.vnet.net>

On 3 Sep 2009, at 11:41, pfalloon wrote:

> On Sep 2, 6:06 pm, "David Park" <djmp... at comcast.net> wrote:
>> If[x == 0, x, 0];
>> FullSimplify[%]
>> 0
>>
>> Piecewise[{{x, x == 0}}, 0];
>> FullSimplify[%]
>> 0
>>
>> David Park
>> djmp... at comcast.nethttp://home.comcast.net/~djmpark/
>>
>> From: beep.beep [mailto:meph... at gmail.com]
>>
>> Hi,
>>
>> When I try to Simplify[If[x==0,x,0]] Mathematica returns If[x==0,=
> x,0] rather
>> than 0. It seems that it does not take into account that left and  
>> right
>> if-branches should be simplified using ($Assumptions)&&if-condition  
>> and
>> ($Assumptions)&&!if-condition respectively. Is there a way to force  
>> that
>> behaviour?
>>
>> Best regards,
>> Ilya
>
> 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[11]:= With[{x=1`20-1}, If[x==0,x,0]]
> Out[11]= 0.*10^-20
>
> Is this intentional?
>

Why is this incorrect (in Mathematica)? After all:

With[{x = 0.}, If[x == 0, x, 0]] == 0
True

With[{x = 1.`20. - 1}, If[x == 0, x, 0]] == 0
True

Of course it is a matter of interpretation but since all these values  
lie in the same equivalence class under Equal it is at least  
consistent to return any one of them as the output of FullSimplify and  
0 is the most natural one to choose.

Andrzej Kozlowski



  • Prev by Date: Re: how to solve the integer equation Abs[3^x-2^y]=1
  • Next by Date: Re: Mapping to a specific column or row in a matrix
  • Previous by thread: Re: Re: Simplifying If expressions
  • Next by thread: Re: Simplifying If expressions