2
$\begingroup$

I have run into some rather strange behavior regarding plotting over regions defined by ImplicitRegion. I have a condition given by

cond = (1 - 4 q^2)^2 (-19 - 88 q^2 + 144 q^4 + 12 (1 - 4 q^2)^2 Cos[a] + (-1 - 8 q^2 + 48 q^4) Cos[2 a])^2 (-1803 + 7732 q^2 + 5744 q^4 + 5568 q^6 + 12 (33 + 644 q^2 + 816 q^4 + 704 q^6) Cos[a] + 4 (35 + 16 q^2 (4 + 79 q^2 + 56 q^4)) Cos[2 a] + 12 (-1 - 20 q^2 + 80 q^4 + 64 q^6) Cos[3 a] + (-1 + 4 q^2)^3 Cos[4 a]) Sin[a]^2

I define an region with

region = ImplicitRegion[{cond>0 && 0<q<0.5 && 0<a<Pi},{q,a}];

As an example, when I then call

ContourPlot[q*a, Element[{q, a}, region]]

I get the following output, which works great.

successful contour plot

However, for one particular case I need to define a slightly different region.

region2 = ImplicitRegion[{cond>0.1 && 0<q<0.5 && 0<a<Pi},{q,a}];

However, now the region is completely useless. It will not produce anything with RegionPlot and when ContourPlot is called it just returns the following:

bad call

Has anyone had any experience with this kind of behavior?

$\endgroup$
3
  • 1
    $\begingroup$ stabRegion is blue in your screenshot, indicating that it doesn't have a value assigned. Are you sure you evaluated all definitions, and that you are using the correct variable name? $\endgroup$
    – Lukas Lang
    Apr 30 at 18:14
  • $\begingroup$ Yes - this is just a screenshot from a few days after. I did not want to rerun it as it took ~20 minutes to return nothing. $\endgroup$
    – JamesVR
    Apr 30 at 19:14
  • $\begingroup$ Try ContourPlot[q*a, Element[{q, a}, DiscretizeRegion@reg]] $\endgroup$
    – Michael E2
    May 1 at 13:35
3
$\begingroup$

Edit

We can directly use RegionFunction

cond = (1 - 4 q^2)^2 (-19 - 88 q^2 + 144 q^4 + 
      12 (1 - 4 q^2)^2 Cos[a] + (-1 - 8 q^2 + 48 q^4) Cos[
        2 a])^2 (-1803 + 7732 q^2 + 5744 q^4 + 5568 q^6 + 
     12 (33 + 644 q^2 + 816 q^4 + 704 q^6) Cos[a] + 
     4 (35 + 16 q^2 (4 + 79 q^2 + 56 q^4)) Cos[2 a] + 
     12 (-1 - 20 q^2 + 80 q^4 + 64 q^6) Cos[3 a] + (-1 + 4 q^2)^3 Cos[
       4 a]) Sin[a]^2;
ContourPlot[q*a, {q, 0, 0.5}, {a, 0, Pi}, 
 RegionFunction -> 
  Function[{q, a}, 
   cond > 0.1 && 0 < q < 0.5 && 0 < a < Pi // Evaluate], 
 AspectRatio -> Automatic]

Or

cond = (1 - 4 q^2)^2 (-19 - 88 q^2 + 144 q^4 + 
      12 (1 - 4 q^2)^2 Cos[a] + (-1 - 8 q^2 + 48 q^4) Cos[
        2 a])^2 (-1803 + 7732 q^2 + 5744 q^4 + 5568 q^6 + 
     12 (33 + 644 q^2 + 816 q^4 + 704 q^6) Cos[a] + 
     4 (35 + 16 q^2 (4 + 79 q^2 + 56 q^4)) Cos[2 a] + 
     12 (-1 - 20 q^2 + 80 q^4 + 64 q^6) Cos[3 a] + (-1 + 4 q^2)^3 Cos[
       4 a]) Sin[a]^2;
region2 = 
  ImplicitRegion[{cond > 0.1 && 0 < q < 0.5 && 0 < a < Pi}, {q, a}];
ContourPlot[q*a, {q, 0, .5}, {a, 0, Pi}, 
 RegionFunction -> Function[{q, a}, {q, a} ∈ region2]]

Original

We can use DiscretizeRegion

cond = (1 - 4 q^2)^2 (-19 - 88 q^2 + 144 q^4 + 
      12 (1 - 4 q^2)^2 Cos[a] + (-1 - 8 q^2 + 48 q^4) Cos[
        2 a])^2 (-1803 + 7732 q^2 + 5744 q^4 + 5568 q^6 + 
     12 (33 + 644 q^2 + 816 q^4 + 704 q^6) Cos[a] + 
     4 (35 + 16 q^2 (4 + 79 q^2 + 56 q^4)) Cos[2 a] + 
     12 (-1 - 20 q^2 + 80 q^4 + 64 q^6) Cos[3 a] + (-1 + 4 q^2)^3 Cos[
       4 a]) Sin[a]^2;
region2 = 
  ImplicitRegion[{cond > 0.1 && 0 < q < 0.5 && 0 < a < Pi}, {q, a}];
disretegion2 = DiscretizeRegion[region2, MaxCellMeasure -> 0.001]
ContourPlot[q*a, Element[{q, a}, disretegion2]]

enter image description here

If we set cond > 1000, then we get enter image description here

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.