MathGroup Archive 2009

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

Search the Archive

Re: Simplifying If expressions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102933] Re: Simplifying If expressions
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Wed, 2 Sep 2009 04:05:42 -0400 (EDT)

On 9/1/09 at 3:53 AM, mephi42 at gmail.com (beep.beep) wrote:

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

Clearly, you must have not assigned a value to x or have a
non-numeric value assigned to x when Mathematica tries to
evaluate If[x==0,x,0]. Mathematica is returning this as the
result because it cannot determine whether x is equal to or not.

Possibly what you want is

If[x===0, x, 0]

This will return 0 when x has no assigned value since a symbol
is not identical 0.

Another possibility is

If[x==0, x, 0, 0]

which will return 0 if x is not equal 0 or if Mathematica cannot
determine whether x is equal to zero or not.

Simplify cannot correct the fundamental issue here and is not needed.



  • Prev by Date: Re: Two Questions
  • Next by Date: Re: Size of numerical slider value in Manipulate
  • Previous by thread: Re: Simplifying If expressions
  • Next by thread: Re: Simplifying If expressions