MathGroup Archive 2004

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

Search the Archive

RE: function IF with several equality conditions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg49105] RE: [mg49081] function IF with several equality conditions
  • From: "David Park" <djmp at earthlink.net>
  • Date: Thu, 1 Jul 2004 05:25:58 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Mukhtar,

Use the And function, which could be clicked off the BasicInput palette.
(Looks like ^.) Or type &&.

a = 1;
Table[If[x1 > a \[And] x2 < a, 0, 1], {x1, 0, 2}, {x2, 0, 2}]
{{1, 1, 1}, {1, 1, 1}, {0, 1, 1}}

In Mathematica = means Set, and == is the Equal logical statement. So for
your second case...

a = 1;
Table[If[x == a, 0, 1], {x, 0, 2}]
{1, 0, 1}

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/


From: Mukhtar Bekkali [mailto:mbekkali at gmail.com]
To: mathgroup at smc.vnet.net

I have two questions that HELP file of Mathematica does not address:

(1) How do I implement IF with several conditions.  I tried something like
this

a=1;
Table[If[{x1>a,x2<a},0,1],{x1,0,2},{x2,0,2}]

and get no results.

Also, (2) IF does not accept equality conditions either, say

a=1;
Table[If[x=a,0,1],{x,0,2}]

I am surprised that such simple things are not covered by help file.

Thank you in advance, Mukhtar




  • Prev by Date: Re: function IF with several equality conditions
  • Next by Date: Re: Re: Union - simple question
  • Previous by thread: Re: function IF with several equality conditions
  • Next by thread: Re: function IF with several equality conditions