I want to plot a system of equalities and inequalities. I used a combination of ImplicitRegion and RegionPlot (since RegionPlot cannot plot lines or points). But this method is very slow than using only the RegionPlot. Can this be improved?
Or is there any other alternate to plot a system of equalities and inequalities?
RegionPlot[x^2 + y^3 < 2 && x + y < 1, {x, -2, 2}, {y, -2, 2}]; // AbsoluteTiming
(*{0.146477,Null}*)
RegionPlot[x^2 + y^3 < 2 && x + y == 1, {x, -2, 2}, {y, -2, 2}]; // AbsoluteTiming
(*{0.0746052,Null}*)
reg1 := ImplicitRegion[x^2 + y^3 < 2 && x + y < 1, {x, y}]
reg2 := ImplicitRegion[x^2 + y^3 < 2 && x + y == 1, {x, y}]
RegionPlot[reg1]; // AbsoluteTiming
(*{0.875837,Null}*)
RegionPlot[reg2]; // AbsoluteTiming
(*{0.405988,Null}*)
(I dont always know the solution range)
UPDATE
I learnt from the comments that one of the reason for RegionPlot[ImplicitRegion[]]
to be slower compared to RegionPlot
is the necessity to find the region bounds in the former. So I tried to find the bounds using RegionBounds
and apply in RegionPlot
. However this combo is slower compared to using RegionPlot
directly on the ImplicitRegion
Also, the third case in the example code I posted may work faster in many of your machines (then I believe the first case with only RegionPlot will be much faster in you machine). My question is a general way to speed up the working of RegionPlot[ImplicitRegion[]]
when compared to RegionPlot
. If that is impossible, I want to know if there is any other way to plot this? (For example, depending on the RegionDimension
, choose RegionPlot
or ContorPlot
. Though this approach also involves the knowledge of the bounds)
DiscretizeGraphics@RegionPlot[<inequality>]
with the output ofRegionPlot[reg1]
etc. $\endgroup$RegionPlot[RegionMember[reg1, {x, y}], {x, -2, 2}, {y, -2, 2}]
? You save time by (I think) not computing the boundary. Note the difference in output though. I'm not sure if that's what you want. If you want the boundary computed automatically, it's going to take extra time to do it -- I don't think there's a way around it. $\endgroup$