Message Boards Message Boards

1
|
2978 Views
|
3 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Create a RegionPlot with an inequality over an intervall of a variable?

Posted 7 years ago

Hello community, I'm new here and also a beginner in mathematica.

I want to do an RegionPlot in mathematica, but my provided inequality should hold over an intervall of a third variable. An example of my problem:

f[x_, y_, z_] = x + y*z;

RegionPlot[f[x, y, z] > 0, {x, -2, 2}, {y, -2, 2} for {z, -0.5, 0.5}]

Sorry, I know that it is not possible in this way however I hope that someone understand what I want to do.

Thank You for answering!

POSTED BY: Tobias Frohoff
3 Replies
Posted 7 years ago

That's exactly what I was looking for. My function is quiet difficult, so that I need your difficult case with "And" as logical operation.

Thanks a lot!

POSTED BY: Tobias Frohoff

For more difficult cases one can make a helper function that will check if a point belongs to a region or not. Here is a simple function that tries to do it numerically:

ClearAll[Envelope]
Envelope[f_, x_?NumericQ, y_?NumericQ, {a_?NumericQ, b_?NumericQ, n_Integer: 100}, comb_: Or] := comb @@ Table[f[x, y, z] > 0, {z, Subdivide[a, b, n]}]

f[x_, y_, z_] := x + z y + Sin[6 z];
Quiet@RegionPlot[Envelope[f, x, y, {-0.5, 0.5}], {x, -2, 2}, {y, -2, 2}]
Quiet@RegionPlot[Envelope[f, x, y, {-0.5, 0.5}, And], {x, -2, 2}, {y, -2, 2}]

enter image description here

For this function one can not simply take the end points as the function is not monotonically increasing. This function will take several points of z and check if they belong to the set, and then using either OR or AND decide what to do.

POSTED BY: Sander Huisman

In general this can be very tricky, as you have to calculate what (I believe) is called an envelope. However you problem is not completely specified. Do you want to the inequality to hold for ALL z, or for SOME z? Depending on this the answer is different. Since you're function is easy one can just evaluate the end-points of 'z' and use logical operations on that:

f[x_, y_, z_] := x + y*z;
RegionPlot[f[x, y, 0.5] > 0 \[And] f[x, y, -0.5] > 0, {x, -2, 2}, {y, -2, 2}]
RegionPlot[f[x, y, 0.5] > 0 \[Or] f[x, y, -0.5] > 0, {x, -2, 2}, {y, -2, 2}]

enter image description here

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract