MathGroup Archive 2007

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

Search the Archive

Re: Limiting range of variables when defining funxtions of several variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74748] Re: [mg74676] Limiting range of variables when defining funxtions of several variables
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Tue, 3 Apr 2007 00:31:31 -0400 (EDT)
  • References: <200703310627.BAA02986@smc.vnet.net>

On Mar 31, 2007, at 2:27 AM, Michelasso wrote:

> Hello everybody,
> my problem is that I would like to plot a 3d graphic of a function of
> two variables, restricted to domain D={(x,y): x>= 0, y>=0, y <= 1-x}.
>
> I thought to define the function in this way:
> test[x_,y_/; y <= 1-x]:= x+y
>
> but this seems not to work, while it works for functions of one
> variable, i.e.:
> test2[x_/; x<= 1]:= 3x
>
> So, am I doing some syntax error, or is there some other kind of
> problems with my definition?

The problem is what information is available when the test is  
performed, in this case the test is performed when the pattern for y  
is matched but x in the conditional expression is not the result of  
pattern matching.  In general if you need to test conditions that  
depend on multiple arguments move the condition test to the right  
hand side of the definition:

test[x_,y_]:=x+y/;y<=1-x

Regards,

Ssezi



  • Prev by Date: Re: Timing in Mathematica
  • Next by Date: Series and order
  • Previous by thread: summation is equivalent to dot product??
  • Next by thread: Series and order