MathGroup Archive 2009

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

Search the Archive

Re: Simplifying If expressions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102931] Re: Simplifying If expressions
  • From: pfalloon <pfalloon at gmail.com>
  • Date: Wed, 2 Sep 2009 04:05:20 -0400 (EDT)
  • References: <h7ijt0$ial$1@smc.vnet.net>

On Sep 1, 5:53 pm, "beep.beep" <meph... at gmail.com> wrote:
> 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

It doesn't work because x==0 may be True, but that doesn't mean x is
exactly zero. e.g.

In[3]:= 0.==0
Out[3]= True

You want to use SameQ (===) instead (and then you don't even need the
Simplify):

In[1]:= If[x===0,x,0]
Out[1]= 0

Cheers,
Peter.


  • Prev by Date: Re: Simplifying If expressions
  • Next by Date: Re: Two Questions
  • Previous by thread: Re: Simplifying If expressions
  • Next by thread: Re: Simplifying If expressions