MathGroup Archive 2007

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

Search the Archive

Re: Limiting range of variables when defining funxtions of several

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74707] Re: Limiting range of variables when defining funxtions of several
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sun, 1 Apr 2007 04:18:43 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <eukv3v$3hr$1@smc.vnet.net>

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?

You should use the Boole function [1] to define a function over a 
region. For instance,

In[1]:=
Clear[test]
test[x_, y_] := (x + y)*Boole[x >= 0 && y >= 0 && y <= 1 - x]
Plot3D[test[x, y], {x, -2, 2}, {y, -2, 2}];

[...graphic deleted...]

Regards,
Jean-Marc

[1] http://documents.wolfram.com/mathematica/functions/Boole

[2] _The Mathematica Book_, "3.5.9 Integrals over Regions",
http://documents.wolfram.com/mathematica/book/section-3.5.9


  • Prev by Date: Kernel closes after nested function returns
  • Next by Date: Re: Limiting range of variables when defining funxtions
  • Previous by thread: Re: Kernel closes after nested function returns
  • Next by thread: Re: How to set SVD options?