Message Boards Message Boards

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

GROUPS:
mathematics calculus graphics and visualization wolfram language

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
Answer
1 month ago

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
Answer
1 month ago

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
Answer
1 month 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
Answer
1 month ago

Group Abstract Group Abstract