# Plotting the image of a region in $\mathbb{R}^3$ defined by an inequality under a map

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.

• Please give the specific example functions. – David G. Stork Jun 1 '17 at 22:43

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[]]] • 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$. – Geardaddy Sep 4 '17 at 15:41
• 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 – Geardaddy Sep 4 '17 at 15:50

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[]^2 + q[], 3 q[]^2 - q[], q[] + q[]};


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]

• 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. – Geardaddy Jun 2 '17 at 18:17