2
$\begingroup$

Firstly, I wrote the following code to specifiy the domain of the variables a and x:

equ = -504 a (-1 + x)^9 - (
   2 (4 (-1 + x)^3 x + a (3 + x (-13 - 4 (-3 + x) x)))^4)/(-1 + 
     x)^3 + 2 x (2 (-1 + x)^3 (-1 + 2 x) + 
      a (3 + x (-13 - 4 (-3 + x) x)))^3 - 
   4 (4 + 193 a) (-1 + x)^6 (-4 (-1 + x)^3 x + 
      a (-3 + x (13 + 4 (-3 + x) x))) - 
   24 (1 + 16 a) (-1 + x)^3 (-4 (-1 + x)^3 x + 
      a (-3 + x (13 + 4 (-3 + x) x)))^2 - 
   4 (3 + 16 a) (-4 (-1 + x)^3 x + a (-3 + x (13 + 4 (-3 + x) x)))^3;

Plot[{2 x + x^2 /. 
   NSolve[{equ == 0, 0 < x < 1/2, 
     2 (-1 + x)^3 < 
      4 x^4 + 3 a + 12 x^2 (1 + a) - 4 x^3 (3 + a) - x (4 + 13 a) < 
      0}, x], x /. 
   NSolve[{equ == 0, 0 < x < 1/2, 
     2 (-1 + x)^3 < 
      4 x^4 + 3 a + 12 x^2 (1 + a) - 4 x^3 (3 + a) - x (4 + 13 a) < 
      0}, x]}, {a, 0, 1.5}, AxesOrigin -> {0, 0}, AxesLabel -> {a, f},
  PlotStyle -> {Red, Blue}, PlotRange -> All, Filling -> {1 -> {2}}]

The output is the following: enter image description here

As shown in the graph, the domain of the variables a and x is the shaded area. It is the region between two curves defined by 2 x + x^2 and x with 0 <= a <= 1.5, where x is an implicit function of a such that equ == 0.

Now my question is that: how to plot the sub-region defined by the following inequality within the specified domain shown in the above graph?

1/(x + 1) + Log[x + 1]/(x + 1)^3 + x^2 > 0.8 a*x + 1/(a^5*x^2 + 1)

I'm thinking about using code RegionPlot to plot it. However, it seems that RegionPlot can only show the region within a rectangle (something like a1 < a < a2 and x1 < x < x2). But in this problem, the domain is not a rectangle. So how can I solve this problem?

BTW, as a try to find the answer, I used RegionPlot to show the region defined by the inequality within a rectangle with 0 < a < 1.5 and 0 < x < 1. Then I used Show to combine the two graphs to obtain the common area of the two graphs, which should be the answer to this question. The code is as follows:

RegionPlot[
  1/(x + 1) + Log[x + 1]/(x + 1)^3 + x^2 > 
   0.8 a*x + 1/(a^5*x^2 + 1), {a, 0, 1.5}, {x, 0, 1}, 
  AxesOrigin -> {0, 0}, PlotRange -> {{0, 1.6}, {0, 1}}, 
  PlotTheme -> "Classic"];

Show[%3214, %3211]

The output is the following: enter image description here

As displayed in the above graph, the common area (shown in purple color) is the answer to this question. However, it is NOT perfect, because I want to show the region defined by the inequality within the specified domain (so the blue area is redundant and should be removed). Is there some way to solve this problem perfectly?

$\endgroup$
3
  • $\begingroup$ Please fix the code Show[%3172, %3211]. $\endgroup$
    – xzczd
    Sep 1, 2023 at 5:29
  • $\begingroup$ Thanks. I have updated the post. $\endgroup$
    – Ya He
    Sep 1, 2023 at 11:34
  • $\begingroup$ …Please remove those % from the code so we can easily test it. $\endgroup$
    – xzczd
    Sep 2, 2023 at 0:01

2 Answers 2

3
$\begingroup$

Though we can plot such intersection, but I still agree with @xzczd and @Bob Hanlon that we have change the original implicit function since{a,x}->{a,2 x + x^2}

equ = -504 a (-1 + 
      x)^9 - (2 (4 (-1 + x)^3 x + 
        a (3 + x (-13 - 4 (-3 + x) x)))^4)/(-1 + x)^3 + 
  2 x (2 (-1 + x)^3 (-1 + 2 x) + a (3 + x (-13 - 4 (-3 + x) x)))^3 - 
  4 (4 + 193 a) (-1 + x)^6 (-4 (-1 + x)^3 x + 
     a (-3 + x (13 + 4 (-3 + x) x))) - 
  24 (1 + 16 a) (-1 + x)^3 (-4 (-1 + x)^3 x + 
      a (-3 + x (13 + 4 (-3 + x) x)))^2 - 
  4 (3 + 16 a) (-4 (-1 + x)^3 x + 
      a (-3 + x (13 + 4 (-3 + x) x)))^3; 

domain = 
 ContourPlot[equ == 0, {a, 0, 1.6}, {x, 0, 1/2}, PlotPoints -> 80, 
  MaxRecursion -> 4, PlotRange -> All];
pts = Cases[domain // Normal, Line[pt_] :> pt, -1];
tranpts = pts /. {a_Real, x_Real} :> {a, 2 x + x^2};
reg1 = Polygon[Join[pts[[1]], Reverse@tranpts[[1]]]];
reg2 = ImplicitRegion[
    1/(x + 1) + Log[x + 1]/(x + 1)^3 + x^2 > 
     0.8 a*x + 1/(a^5*x^2 + 1), {{a, 0, 1.5}, {x, 0, 1}}] // 
   BoundaryDiscretizeRegion;
intersection = RegionIntersection[reg1, reg2];
Graphics[{{Opacity[.2], Green, reg1}, {Red, intersection}, {Thick, 
   ColorData[97][1], Line[pts], Line[tranpts]}}, Axes -> True, 
 PlotRange -> All]

enter image description here

$\endgroup$
1
  • $\begingroup$ Many thanks for your answer. I have one question: can you remove the blue area in your graph? I don't want to show this area, because the question in my post is that "showing the sub-region defined by the inequality within the specified doman (i.e., the green area in your graph)". The blue area is redundant. $\endgroup$
    – Ya He
    Sep 1, 2023 at 11:22
2
$\begingroup$
$Version

(* "13.3.1 for Mac OS X ARM (64-bit) (July 24, 2023)" *)

Clear["Global`*"]

equ = -504 a (-1 + 
       x)^9 - (2 (4 (-1 + x)^3 x + 
         a (3 + x (-13 - 4 (-3 + x) x)))^4)/(-1 + x)^3 + 
   2 x (2 (-1 + x)^3 (-1 + 2 x) + a (3 + x (-13 - 4 (-3 + x) x)))^3 - 
   4 (4 + 193 a) (-1 + x)^6 (-4 (-1 + x)^3 x + 
      a (-3 + x (13 + 4 (-3 + x) x))) - 
   24 (1 + 16 a) (-1 + x)^3 (-4 (-1 + x)^3 x + 
       a (-3 + x (13 + 4 (-3 + x) x)))^2 - 
   4 (3 + 16 a) (-4 (-1 + x)^3 x + a (-3 + x (13 + 4 (-3 + x) x)))^3;

xval = Assuming[{0 < x < 1/2, 0 < a < 3/2},
    Solve[{equ == 0, 0 < x < 1/2, 0 < a < 3/2}, x] // Simplify][[1]];

Show[
 Plot[{2 x + x^2 /. xval, x /. xval}, {a, 0, 3/2},
  AxesOrigin -> {0, 0},
  AxesLabel -> (Style[#, 14] & /@ {a, f}),
  PlotStyle -> {Red, Blue},
  PlotRange -> All,
  Filling -> {1 -> {2}},
  PlotLegends -> Placed[{2 x + x^2, x}, {.5, .2}],
  WorkingPrecision -> 15],
 RegionPlot[
  Evaluate[x <= y <= 2 x + x^2 &&
      1/(x + 1) + Log[x + 1]/(x + 1)^3 + x^2 > 
       4/5 a*x + 1/(a^5*x^2 + 1) /. xval] && 0 <= a <= 3/2,
  {a, 0, 3/2}, {y, 0, 4/5},
  PlotStyle -> Opacity[0.75, Yellow],
  BoundaryStyle -> {Gray, Thin},
  WorkingPrecision -> 15]]

enter image description here

$\endgroup$
10
  • $\begingroup$ Thanks for your answer. But it seems not correct. Pls read my post (I just updated it). $\endgroup$
    – Ya He
    Sep 1, 2023 at 3:30
  • $\begingroup$ When the plots are overlapped they must be drawn on the same axes. The vertical axes in your original plot is not x, it is f or y or whatever you want to call it other than x. In the subregion, x must be same as x in the larger region, i.e., defined by the solution to equ == 0. $\endgroup$
    – Bob Hanlon
    Sep 1, 2023 at 3:40
  • $\begingroup$ Thanks for your reply. I don't think it's relevant to call x f or y. Pls notice that x is an implicit function of a. Indeed, x and a have to satisfy equ (a, x) == 0. $\endgroup$
    – Ya He
    Sep 1, 2023 at 3:46
  • 1
    $\begingroup$ I repeat, When the plots are overlapped they must be drawn on the same axes I am leaving this discussion. $\endgroup$
    – Bob Hanlon
    Sep 1, 2023 at 4:05
  • 1
    $\begingroup$ @YaHe Notice in the first Plot[…] you're plotting x and 2 x + x^2. The vertical axis does not represent x at all. $\endgroup$
    – xzczd
    Sep 1, 2023 at 5:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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