MathGroup Archive 2009

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

Search the Archive

Re: Re: Simplifying If expressions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103003] Re: [mg102969] Re: Simplifying If expressions
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Thu, 3 Sep 2009 19:55:08 -0400 (EDT)
  • References: <287030.1251791777166.JavaMail.root@n11> <h7l91h$3cj$1@smc.vnet.net> <200909030941.FAA20932@smc.vnet.net> <614E6D9B-BFF9-434E-B72C-2ACB24FDDD2E@mimuw.edu.pl>

On 3 Sep 2009, at 15:57, Andrzej Kozlowski wrote:

>
> 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
>

Sorry, the very last comment (about choosing 0 as the value returned)  
was the result of a confusion. I meant simply to say that the answer  
returned by FullSimplify is consistent with the fact that all the  
numbers 0, 0.,  1.`20.-1 are Equal in Mathematica.

Andrzej Kozlowski



  • Prev by Date: Re: How to color a 3D surface
  • Next by Date: Multiple conditions in ContourPlot
  • Previous by thread: Re: Simplifying If expressions
  • Next by thread: Re: Re: Simplifying If expressions