MathGroup Archive 2007

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

Search the Archive

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

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:




  • 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