0
|
10304 Views
|
2 Replies
|
0 Total Likes
View groups...
Share

[?] Plot a function with multiple constraints?

Posted 7 years ago
 Hello, I am not able to plot a graph of the function f(x,y) = 2x+y, that is in the domain given by y ? 0, x ? y ? ?1, x + y ? 1. Help would be greatly appreciated!
2 Replies
Sort By:
Posted 7 years ago
 Hello Madis,you can achieve this in the following way:Define the function: In[1]:= f[x_, y_] := 2 x + y Define the domain: In[2]:= cond1 = y >= 0 && x - y >= -1 && x + y <= 1; Using reduce, you can simplify the domain condition: In[3]:= cond2 = Reduce[cond1, {x, y}] (* Out[3]= (x == -1 && y == 0) || (-1 < x <= 0 && 0 <= y <= 1 + x) || (0 < x < 1 && 0 <= y <= 1 - x) || (x == 1 && y == 0) *) The domain condition can be turned into a region using ImplicitRegion: In[4]:= reg1 = ImplicitRegion[ cond2, {{x, -\[Infinity], \[Infinity]}, {y, -\[Infinity], \ \[Infinity]}}]; The region looks like this: In[6]:= RegionPlot[reg1]Next you plot the function over this region using Plot3D: In[7]:= Plot3D[f[x, y], {x, y} \[Element] reg1, AxesLabel -> {"x", "y", "f[x,y]"}] 
Posted 7 years ago
 Does the following code satisfy your needs? Plot3D[2 x + y, {x, 0, 1}, {y, 0, 1}, RegionFunction -> (#2 >= 0 && #1 \[Minus] #2 >= \[Minus]1 && #1 + #2 <= 1 &), BoxRatios -> Automatic, PlotRange -> All] 
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.