1
$\begingroup$

I have two functions:

  • $f: \mathbb{R}^3 \to \mathbb{R}^3$
  • $g: \mathbb{R}^3 \to \mathbb{R}$

I want to plot the image of $\{ (x,y,z) | g(x,y,z)>0 \}$ under $f$. Is there a nice way to do this? The set $g(x,y,z)>0$ is nice, it is topologically a ball but I don't think that there is any nice way to parameterize the surface $g=0$.

EDIT: There are a few different f,g that I am interested in. All are fairly complicated but generally f is the gradient of some scalar function and I want to plot the image of the set where the Hessian of the function is positive semi-definite. (It is actually slightly more complicated than that, and it really involves a function from ${\mathbb R}^4$ to ${\mathbb R}^4$ but I only really care about a particular projection into ${\mathbb R}^3$. One example would be

$g(x,y,z) = \cos (x) \cos (x-y) \cos (x-z)+\cos (x) \cos (y) \cos (x-z)+\cos (y) \cos (x-y) \cos (x-z)+\cos (x) \cos (x-z) \cos (y-z)+\cos (y) \cos (x-z) \cos (y-z)+\cos (z) \cos (x-y) \cos (x-z)+\cos (y) \cos (z) \cos (x-z)+\cos (z) \cos (x-z) \cos (y-z)+\cos (x) \cos (x-y) \cos (y-z)+\cos (x) \cos (y) \cos (y-z)+\cos (y) \cos (x-y) \cos (y-z)+\cos (x) \cos (z) \cos (x-y)+\cos (x) \cos (y) \cos (z)+\cos (y) \cos (z) \cos (x-y)+\cos (x) \cos (z) \cos (y-z)+\cos (z) \cos (x-y) \cos (y-z)$

$f_1(x,y,z) = \frac{-2 \sin (x-y)-\sin (x-z)-\sin (x)+\sin (y-z)+\sin (y)}{\sqrt{2}}$

$f_2(x,y,z) = -\frac{3 \sin (x-z)+\sin (x)+3 \sin (y-z)+\sin (y)-2 \sin (z)}{\sqrt{6}}$

$f_3(x,y,z) = -\frac{2 (\sin (x)+\sin (y)+\sin (z))}{\sqrt{3}}$

I'd be interested in the image of the region containing the origin where g is positive. There is a second piece of the set $g>0$ that does not contain the origin but I am not interested in that piece.

$\endgroup$
1
  • 2
    $\begingroup$ Please give the specific example functions. $\endgroup$ Commented Jun 1, 2017 at 22:43

2 Answers 2

2
$\begingroup$

Perhaps ContourPlot3D and RegionFunction would be useful, for example:

Show[ContourPlot3D[x  y z, {x, -1, 1}, {y, -1, 1}, {z, -1, 1}, 
  Contours -> 10, Mesh -> None, ContourStyle -> Opacity[0.6], 
  PlotLegends -> Automatic, 
  RegionFunction -> Function[{x, y, z}, x^2 + y^2 + z^2 > 1]], 
 Graphics3D[Sphere[]]]

enter image description here

$\endgroup$
2
  • $\begingroup$ This is a nice plot but I don't think that it does what I need. If I understand the code correctly it plots (for instance) the set of points such that $x y z = 0.0909$ with the constraint that $x^2 + y^2 + z^2 > 1$. This is not what I need. What I would like is to find the set of points such that $g(x,y,z) = 0.0909$ (giving some surface in $R^3$) and then plot the image of the image of that surface under some map $f:R^3\mapsto R^3$. $\endgroup$
    – Geardaddy
    Commented Sep 4, 2017 at 15:41
  • $\begingroup$ So for example, I might like to find the surface in $(x,y,z)$ such that $x^2 + x^4 + y^2 + y^6 + z^2 + 0.1 z^4 =1$, and then find out what that surface looks like in $(u,v,w)$ under the map $u=x+y^2 + z^3, v = y - 0.1 z^2, w = z + x + y - z^3.$ (My actual map is somewhat different and more complicated but is conceptually similar.) I don't have an explicit parameterization of the surface or I would use ContourPlot3D $\endgroup$
    – Geardaddy
    Commented Sep 4, 2017 at 15:50
0
$\begingroup$

Here is a very awkward approach, but one that works.

First get a set of points that lie in $g$:

inGpoints = Select[Flatten[Table[If[x^2 + 2 y^2 + 3 z^2 < 1, {x, y, z}], 
     {x, -2, 2, .1}, {y, -2, 2, .1}, {z, -2, 2, .1}], 2], 
   Length[#] == 3 &];

Now define your $f$ function:

f[q_List] := {2 q[[1]]^2 + q[[2]], 3 q[[3]]^2 - q[[1]], q[[3]] + q[[2]]};

Now apply $f$ to the points that satisfy your $g$ constraint:

finalpoints = f /@ inGpoints;

Now plot the outer boundary of these final points:

ConvexHullMesh[finalpoints]
$\endgroup$
1
  • 2
    $\begingroup$ Thanks! This looks pretty good. I actually know rigorously that the image is convex, so taking the convex hull is OK, but it is worth pointing out that if the image is not convex the convex hull mesh might look very different from the actual image. $\endgroup$
    – Geardaddy
    Commented Jun 2, 2017 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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