# RegionPlot avoiding some complex terms

I have a system of inequalities given as follows:

ineq = (x==Root[-2287557518841856-1582539808258048 #1-276834000167424 #1^2-26727972939520 #1^3-22862182923648 #1^4-7840589067776 #1^5-571069189368 #1^6+96523308848 #1^7+12136306416 #1^8+467945774 #1^9+5289607 #1^10-81335 #1^11-1717 #1^12+3 #1^13&,3]&&y==Root[11523925536-7498974464 x+1872685056 x^2-205275136 x^3+8388608 x^4+(1738227248-845268480 x+136332288 x^2-6930432 x^3) #1+(97241168-31018880 x+2362880 x^2-4096 x^3) #1^2+(2389656-375168 x+2816 x^2) #1^3+(22570-592 x) #1^4+39 #1^5&,3])||(x==Root[-2287557518841856-1582539808258048 #1-276834000167424 #1^2-26727972939520 #1^3-22862182923648 #1^4-7840589067776 #1^5-571069189368 #1^6+96523308848 #1^7+12136306416 #1^8+467945774 #1^9+5289607 #1^10-81335 #1^11-1717 #1^12+3 #1^13&,4]&&y==Root[11523925536-7498974464 x+1872685056 x^2-205275136 x^3+8388608 x^4+(1738227248-845268480 x+136332288 x^2-6930432 x^3) #1+(97241168-31018880 x+2362880 x^2-4096 x^3) #1^2+(2389656-375168 x+2816 x^2) #1^3+(22570-592 x) #1^4+39 #1^5&,3])||(Root[11523925536-7498974464 x+1872685056 x^2-205275136 x^3+8388608 x^4+(1738227248-845268480 x+136332288 x^2-6930432 x^3) #1+(97241168-31018880 x+2362880 x^2-4096 x^3) #1^2+(2389656-375168 x+2816 x^2) #1^3+(22570-592 x) #1^4+39 #1^5&,3]<=y<=Root[11523925536-7498974464 x+1872685056 x^2-205275136 x^3+8388608 x^4+(1738227248-845268480 x+136332288 x^2-6930432 x^3) #1+(97241168-31018880 x+2362880 x^2-4096 x^3) #1^2+(2389656-375168 x+2816 x^2) #1^3+(22570-592 x) #1^4+39 #1^5&,4]&&Root[-2287557518841856-1582539808258048 #1-276834000167424 #1^2-26727972939520 #1^3-22862182923648 #1^4-7840589067776 #1^5-571069189368 #1^6+96523308848 #1^7+12136306416 #1^8+467945774 #1^9+5289607 #1^10-81335 #1^11-1717 #1^12+3 #1^13&,3]<x<Root[-2287557518841856-1582539808258048 #1-276834000167424 #1^2-26727972939520 #1^3-22862182923648 #1^4-7840589067776 #1^5-571069189368 #1^6+96523308848 #1^7+12136306416 #1^8+467945774 #1^9+5289607 #1^10-81335 #1^11-1717 #1^12+3 #1^13&,4]);


The two terms are just some points and the last term is defined by a semialgebraic set bounded by the segment of a curve first defined by an interval where $$x$$ may lie and secondly defined by another interval where $$y$$ may lie but the interval of $$y$$ is dependent on the value of $$x$$. I tried to sketch this with RegionPlot. But the problem is that Mathematica does not understand that when the interval for $$y$$ evaluates to some some imaginary number then it should not plot it. It gives me some error if I do something like this:

RegionPlot[ineq, {x, -4.7, -2.3}, {y, -47, -23}]


But if I plot by

RegionPlot[ineq, {x, -4.6, -2.3}, {y, -47, -30}]


I get some of the region that I want plotted, however the portion (some ends of the "balloon") is cut-off. See this image: However, I want the whole region and I don't know how to ask Mathematica to disregard some imaginary evaluation for the interval for $$y$$ in order to avoid the errors (the errors are Invalid comparison). Any ideas?

• Your first image shows that the region lies between -4.7<x<-2.4. That's why your second plot cuts the region at x==-4.6 . In MMA 11.0.1 the behavior seems to be ok! Jul 24, 2019 at 13:14
• Ah so probably this is a MMA 10.xx issue (I am using 10.xx right now). I will have to update. Thanks Jul 24, 2019 at 14:28
• I still get the error even for MMA 11.0.1. But at least there is a plot Jul 24, 2019 at 14:54

Here as an extended comment (Mathematica version 11.0.1 Windows):

RegionPlot[ineq, {x, -5, -2. }, {y, -50, -30}, PlotRange -> Full,MaxRecursion -> 4]


shows the complete region (without error messages)!

The plot is cut as expected, if you reduce the x-range (your plot 2)

RegionPlot[ineq, {x, -4.6, -2.3}, {y, -47, -30}] • this is unusual. I get the same plot but with error messages and I also use now MMA 11.0.1.0 (student's edition). The plot in itself are fine just the error message are annoying but still tolerable. Jul 24, 2019 at 15:08
• Did you restart your kernel ? Which error messages did you get? Jul 24, 2019 at 15:09
• Yes, that I did too. I even restarted Mathematica altogether. The error is "Invalid comparison" simply because there are complex evaluation for the ranges of y if you increase the interval (so plot shows as yours, just the error shows as well). Decreasing the interval for x will not give you complex evaluate for ranges of y so I do not get the error. I am just confused why we use the same version of MMA but you don't get that error. Jul 25, 2019 at 6:08

Decouple the plot bounds from the plot range.

xbounds = Cases[ineq, x == xv_ :> xv, Infinity] RegionPlot[ineq,
{x, Evaluate@Sequence @@ xbounds},
{y, -50, -30},
PlotRange -> {{-5, -2}, Automatic}] • Interesting. I don't get the same output after defining xbounds. And after executing RegionPlot I get the error: RegionPlot::pllim: Range specification {x,Evaluate[Sequence]@@xbounds} is not of the form {x, xmin, xmax}. Dec 23, 2019 at 5:34
• I just ran the code again with the same results that I posted. I am running version 12.0 with macOS 10.15.2 From the error message it appears that you have a typo. Your {x,Evaluate[Sequence]@@xbounds} should be either {x, Evaluate@Sequence @@ xbounds}, or {x, Evaluate[Sequence @@ xbounds]} Dec 23, 2019 at 6:01
• The error is misleading indeed. I'm using the same {x, Evaluate@Sequence @@ xbounds}. At the moment I am using Mathematica 11.0 Student Edition (Windows 10). So it's probably the Students edition of the Windows version of Mathematica (since other people don't seem to have this error). Thanks for the help though. In any case, the error I get by directly doing a RegionPlotstill plots the region (which is what I want). It's just a minor annoyance I can live with. Dec 23, 2019 at 6:20
• I recommend that you try it with {x, Evaluate[Sequence @@ xbounds]}  the error message may indicate that there is some difference with the evaluation priorities. Dec 23, 2019 at 6:26