5
$\begingroup$

I'm trying to define the region between two curves, f[x] and g[x], I can easily find where they intersect:

f = Function[x, 12 x^2];

g = Function[x, 3 x^3];

p = {x, g[x]} /. DeleteDuplicates[Solve[g[x] == f[x], x, Reals]];

p1 = First[Take[p, 1]];

p2 = First[Drop[p, 1]];

From there I plot the curves:

plot = Plot[Evaluate@Through[{f, g}@x], {x, 0, 4}, 
  PlotRange -> {{0, 4}, {0, 200}}, 
  Epilog -> {Red, PointSize[0.02], Point@{p1, p2}}, 
  PlotLabels -> Automatic]

And all of that works fine, my problem is when I try and define the intersection of those two regions

rf = ImplicitRegion[y <= f[x], {x, y}];

rg = ImplicitRegion[y >=  g[x], {x, y}];

intersection = RegionIntersection @@ {rf, rg};

Region[rf, PlotRange -> {{0, 4}, {0, 200}}]
$\endgroup$
9
$\begingroup$

Provide the coordinate bounds in the second argument of ImplicitRegion:

rf = ImplicitRegion[y <= f[x], {{x, 0, 4}, {y, 0, 200}}]
ImplicitRegion[y <= 12 x^2 && 0 <= x <= 4 && 0 <= y <= 200, {x, y}]
rg = ImplicitRegion[y >= g[x], {{x, 0, 4}, {y, 0, 200}}]
ImplicitRegion[y >= 3 x^3 && 0 <= x <= 4 && 0 <= y <= 200, {x, y}]
intersection = RegionIntersection @@ {rf, rg};

Region[#, AspectRatio -> 1] & /@ {rf, rg, intersection}

enter image description here

RegionPlot gives a better picture:

RegionPlot /@ {rf, rg, intersection}

enter image description here

RegionPlot[{rf, rg, intersection}]

enter image description here

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you so much, im always missing little details like that, I appreciate the time you put into your answer. $\endgroup$ – Wombles Apr 4 at 23:19
  • $\begingroup$ @Wombles, my pleasure. Thank you for the accept. $\endgroup$ – kglr Apr 4 at 23:50
  • 2
    $\begingroup$ @Wombles - Alternatively, use rf = ImplicitRegion[y <= f[x] && p[[1, 1]] <= x <= p[[2, 1]], {x, y}]; rg = ImplicitRegion[y >= g[x] && p[[1, 1]] <= x <= p[[2, 1]], {x, y}]; $\endgroup$ – Bob Hanlon Apr 5 at 3:23
  • $\begingroup$ @BobHanlon, Thank you, i will give that a try as well! $\endgroup$ – Wombles Apr 5 at 5:07
3
$\begingroup$

Just a direct way to do:

ir = ImplicitRegion[g[x] < y < f[x], {{x, 0, 4}, {y, 0, 200}}];
ra = ImplicitRegion[y > f[x], {{x, 0, 4}, {y, 0, 200}}];
rb = ImplicitRegion[y < g[x], {{x, 0, 4}, {y, 0, 200}}];
rgns = {ir, ra, rb};
leg = First /@ rgns;
RegionPlot[{##}, PlotLegends -> leg] & @@ rgns

enter image description here

| improve this answer | |
$\endgroup$

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.