6
$\begingroup$

I have the following problem:

I would like to do a RegionPlot like

RegionPlot[F[x,z,y]<1,{x,0,1},{y,0,1}]

The problem is that the variable z is an implicit (and not reducable via e.g. Solve, meaning too non-linear) but continuous function of x and y, for example

G[x,y,z]==0.

The functions F and G are well-defined. Would anyone know how to solve this issue in a general way?

$\endgroup$
7
$\begingroup$

You can define the implicit solution for z

bigG[x_?NumberQ, y_?NumberQ] :=  FindRoot[Sin[x + z] + Cos[y + z] == 0, {z, \[Pi]}][[1, 2]]

and then use it in the your F :

bigF[x_?NumberQ, y_?NumberQ] = x^2 + y^2 + 2 x y bigG[x, y]

RegionPlot[bigF[x, y] < 1, {x, 0, 1}, {y, 0, 1}]

test

$\endgroup$
  • $\begingroup$ easy, quick and nice solution. thanks a lot! $\endgroup$ – user2085 Aug 21 '12 at 10:13
  • $\begingroup$ @user2085 welcome to Mathematica.SE. You now have the "reputation" points needed to vote for this answer; please make use if it (since you find it helpful). $\endgroup$ – Mr.Wizard Aug 21 '12 at 11:02
  • $\begingroup$ @Silvia The post did not specify what F,G were so I just made up a quick example for illustration. In particular I am taking the root close to Pi; in this case 0.45^2 + 0.45^2 + 2 0.45 0.45 bigG[0.45, 0.45] = 1.17701 so it seems correct that there is a hole at those coordinates. $\endgroup$ – b.gates.you.know.what Aug 22 '12 at 16:07
  • $\begingroup$ @b.gatessucks I see. I think I misunderstood your code:) comment revoked and +1. $\endgroup$ – Silvia Aug 22 '12 at 16:33
  • $\begingroup$ @Silvia Thanks for checking. $\endgroup$ – b.gates.you.know.what Aug 22 '12 at 16:39
4
$\begingroup$

For surface $G(x,y,z)=0$ which is bounded in $z$ direction on $(x,y)\in[0,1]\times[0,1]$, by specifying large enough $z$-interval, ContourPlot3D with the option RegionFunction can be used to generate the required region graphics.

Take $G(x,y,z)=x^3+y^3+z^3-20$ and $F(x,y,z)=30-(x-2)^4-(y-0.5)^4-0.8 (z-0.5)^4$ as an example.

graph = ContourPlot3D[
 x^3 + y^3 + z^3 - 20 == 0,
 {x, -3, 3}, {y, -3, 3}, {z, -5, 5},
 RegionFunction -> Function[{x, y, z},
   30 - (x - 2)^4 - (y - .5)^4 - .8 (z - .5)^4 < 1],
 BoundaryStyle -> None, Mesh -> None,
 PlotPoints -> 50]

Mathematica graphics

Then convert the 3D graphics to 2D one:

Graphics[{##}[[1]],
   PlotRange -> All, Frame -> True, Axes -> False,
   Sequence @@ Rest[{##}]] & @@
 DeleteCases[graph /.
    GraphicsComplex[pts_, others__] :>
     GraphicsComplex[pts[[All, 1 ;; 2]], others] /.
   Polygon[pts_] :>
    Sequence[FaceForm[{Lighter[Blue, .8]}], EdgeForm[{Lighter[Blue, .8]}], Polygon[pts]],
  _?(MatchQ[#,
      (VertexNormals -> _) | (BoxRatios -> _) | (PlotRangePadding -> _) | (PlotRange -> _)
      ] &), \[Infinity]]

Mathematica graphics

Note: for an unbounded $G(x,y,z)$, it will be much harder to determine whether a point $(x,y)$ satisfies the region condition, and I suppose, as Artes said, impossible to find a general way.

$\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.