Re: Limiting range of variables when defining funxtions

*To*: mathgroup at smc.vnet.net*Subject*: [mg74700] Re: [mg74676] Limiting range of variables when defining funxtions*From*: Bob Hanlon <hanlonr at cox.net>*Date*: Sun, 1 Apr 2007 04:15:08 -0400 (EDT)*Reply-to*: hanlonr at cox.net

Off[Plot3D::plnc,Plot3D::gval]; Clear[test]; test[x_/;0<=x<=1,y_/;0<=y<=1-x]:=x+y; Plot3D[test[x,y],{x,-0.1,1.1},{y,-0.1,1.1}]; Clear[test]; test[x_,y_]:=(x+y)*Boole[0<=x<=1&&0<=y<=1-x]; Plot3D[test[x,y],{x,-0.1,1.1},{y,-0.1,1.1}]; Clear[test]; test[x_,y_]:=Piecewise[ {{x+y,0<=x<=1&&0<=y<=1-x}}]; Plot3D[test[x,y],{x,-0.1,1.1},{y,-0.1,1.1}]; Bob Hanlon ---- Michelasso <qzerty at gmail.com> 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? >