Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
Is G[x,y,z] == 0 algebraic or transcendental? –  J. M. Aug 21 '12 at 10:21
    
There is no general way. You have to restrict smoehow G and F. You can find some related ideas from the answers to this question : mathematica.stackexchange.com/questions/8536/… –  Artes Aug 21 '12 at 10:45

2 Answers 2

up vote 7 down vote accepted

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

share|improve this answer
    
easy, quick and nice solution. thanks a lot! –  user2085 Aug 21 '12 at 10:13
    
@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). –  Mr.Wizard Aug 21 '12 at 11:02
    
@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. –  b.gatessucks Aug 22 '12 at 16:07
    
@b.gatessucks I see. I think I misunderstood your code:) comment revoked and +1. –  Silvia Aug 22 '12 at 16:33
    
@Silvia Thanks for checking. –  b.gatessucks Aug 22 '12 at 16:39

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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