3
$\begingroup$

Why does the plot produced by the following code not contain the point {0. 0}?

Region[ImplicitRegion[y <= x/2 && x >= 0 && y >= 0, {x, y}], 
  PlotRange -> Full, Axes -> True]

enter image description here

Why does the above not plot a wedge starting at 0, like this:

enter image description here

As far as I understand my code, I first define a region that follows the inequalities specified by ImplicitRegion, and then call Region to plot it.

Yet still, I seem to have made a mistake. What is it?

$\endgroup$
  • 1
    $\begingroup$ Using {{x, 0,1}, {y, 0,1}} instead of {x,y} as the second argument fixes the issue. $\endgroup$ – kglr Nov 5 '18 at 15:32
  • 1
    $\begingroup$ RegionPlot works better than Region. Region[DiscretizeRegion@ImplicitRegion[..],..] also works. $\endgroup$ – Michael E2 Nov 5 '18 at 15:58
  • 2
    $\begingroup$ @Sudix I don't think it's a bug. Numerical routines always suffer from discretization errors. I don't think Region is meant to be robust in the way you're using it. I'd recommend DiscretizeRegion as the tool to use. It has options to control the discretization. RegionPlot tries a harder than Region, but it's not as robust as DiscretizeRegion (or the FEM ToElementMesh, which allows even finer control). $\endgroup$ – Michael E2 Nov 5 '18 at 16:14
  • 1
    $\begingroup$ RegionPlot is a 2D plotter, and RegionPlot3D is a 3D plotter. Region is not a plotter. What you see is result of the Front End displaying a 2D Region: it makes a quick plot of it to show in the notebook, but the result of Region is not Graphics. If you want a Region, use Region. The bad picture does not indicate a bad result. In fact, the result is still accurate. Compare Region[..] // InputForm // Short and RegionPlot[..] // InputForm // Short on your region code and my plot. $\endgroup$ – Michael E2 Nov 5 '18 at 16:40
  • 1
    $\begingroup$ For instance, you can use RegionPlot on your Region and you get accurate graphics. You can also use DiscretizeRegion on it. That is, if you want to have your Region[..]. $\endgroup$ – Michael E2 Nov 5 '18 at 16:49
1
$\begingroup$

Edit

The discretization made automatically by Region is a bit strange, but it does satisfy all the condition you give. Perhaps Region's boundary choice is bad enough that the behavior you complain about should be considered a bug.

However, as things stand, to get what you want you must give Region better specifications of the boundary you want. One way to it is

Region[ImplicitRegion[y <= x/2 && x >= 0 && y >= 0, {{x, 0, 4}, {y, 0, 4}}], 
  Axes -> True]

Another is

Region[
 DiscretizeRegion[
   ImplicitRegion[y <= x/2 && x >= 0 && y >= 0, {x, y}], 
   {{0, 4}, {0, 4}}],
 Axes -> True]

Both work-arounds produce

region

$\endgroup$
  • 1
    $\begingroup$ But ImplicitRegion can be used as I did according to the documentation: ImplicitRegion[cond,$\{x_1,...,x_n\}$]; represents a region in $\mathbb{R}^n$ that satisfies the conditions cond. $\endgroup$ – Sudix Nov 5 '18 at 16:30
  • $\begingroup$ @Sudix. Valid point. I have edited my answer in way that I hope addresses it. $\endgroup$ – m_goldberg Nov 5 '18 at 17:42

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.