# Finding positive region of continous function

I want to find (and plot) the positive region (within a certain domain say x<3,y<3) of a function f[x,y] of two variables for a high order polynomial with high precision coefficients. What is an effective way to do this (as automated as possible).

For the one dimensional case I was able to do this by finding the roots using the method proposed in https://mathematica.stackexchange.com/a/16444/45020 and testing positivity in between. For a multivariable function the problem becomes a lot more complicated. However, I am hoping that Mathematica can still determine the intersections between the function and 0. A 3D plot of f[x,y] and 0 suggest that mathematica determines the intersect but how to extract this data and whether there is any accuracy to this I don't know.

I can give as an example function -2 y^2 Sin[x] + y^3 but I am really looking for a solution that would also work for much more complicated functions (too big to include an example here).

I managed to make the desired plot using the option RegionFunction -> (#3 >= 0 &) however I still not know how to determine the intersection (if possible to high precision).

Maybe you can use Region functionality to do this:

reg = ImplicitRegion[-2 y^2 Sin[x] + y^3 > 0, {{x, -3, 3}, {y, -3, 3}}]


ImplicitRegion[y^3 - 2 y^2 Sin[x] > 0 && -3 <= x <= 3 && -3 <= y <= 3, {x, y}]

DiscretizeRegion[reg, Axes->True] If you don't want the mesh, you can instead use:

BoundaryDiscretizeRegion @ reg or:

BoundaryMesh @ DiscretizeRegion @ reg


(same image)

You should be able to use MeshCellStyle as suggested in your comment:

BoundaryDiscretizeRegion[reg, MeshCellStyle -> {2->Red}]
BoundaryMesh[DiscretizeRegion @ reg, MeshCellStyle -> {2 -> Red}]


both produce a red region. Also, you can use MeshRegion/BoundaryMeshRegion on an already existing mesh region to style it further:

MeshRegion[DiscretizeRegion @ reg, MeshCellStyle -> {2->Red, 1->Opacity[.3]}] • Thanks. This is great. Does the mesh grid have real meaning here? Is it how the region was computed? By checking for discrete points and fitting an intersection curve or are they just some strange artifact. Also do you know how I can take tthe grid away and color it uniforml. I tried MeshCellStyle->{1->ColorData,2->ColorData but although the first argument does affect the lines and the second the interior they somehow still don't give the exact same color. (The lines are slightly brighter). – Kvothe May 14 at 15:21

ContourPlot:

cplot = ContourPlot[-2 y^2 Sin[x] + y^3 == 0, {x, -3, 3}, {y, -3, 3}] From here, we can extract the coordinates of the points used to plot the line:

intersection = First@Cases[Normal[cplot], Line[pts_] :> pts, Infinity];
Graphics@Point[intersection] Or if you want to color one of the regions:

polycoords = Join[intersection, {{3, -3}, {-3, -3}}];
Graphics@Polygon[polycoords] This is just meant as an example of what you can do with the points. It's not clear to me what exactly you are trying to do. If you have contours that enclose some region, then ContourShading will allow you to color that region using ContourPlot.