0
$\begingroup$

I have a function of 3 variables: $x$, $y$, and $z$. This is the function: $$f(x,y,z)=x z + y z - x y z$$

  1. Is there a way for me to graph this function? (3D graph)
  2. Can you sketch several representative contour plots from the family of equations for various choices of c. We might place them all together in one plot?
  3. Can this function of three variables be visualized as a 2D grid of 2D contours? As shown in the picture enter image description here

Thanks for the help.

$\endgroup$
2
  • $\begingroup$ You literally named the solution in your title. ContourPlot3D ContourPlot. And for the last one you'll also want to look at Grid. Perhaps also interesting: RegionPlot3D $\endgroup$ Jun 8 '17 at 21:47
  • $\begingroup$ "Modify"?... modify how? "[C]hoice of cc"?... what is "cc"? $\endgroup$ Jun 8 '17 at 22:11
5
$\begingroup$

You (apparently) have a scalar function of three variables, so you cannot use a simple ContourPlot; you must use ContourPlot3D. Moreover 3DPlot (which does not exist in Mathematica but instead Plot3D) takes a function of two variables and plots the value in the third dimension.

Instead you should use this:

DensityPlot3D[x z + y z - x y z, 
          {x, -2, 2}, 
          {y, -2, 2}, 
          {z, -2, 2},
 PlotLegends->Automatic]

enter image description here

If you want contours:

ContourPlot3D[x z + y z - x y z, 
          {x, -2, 2}, 
          {y, -2, 2}, 
          {z, -2, 2},
 Contours -> 10]

enter image description here

If you want two-dimensional slices:

GraphicsGrid[
   Partition[
   Table[
   ContourPlot[x z + y z - x y z, 
            {x, -2, 2}, 
            {y, -2, 2}],
   {z, -2, 2, .5}], 
   3]]

enter image description here

$\endgroup$
4
  • $\begingroup$ Thank you very much for the wonderful work .... Can you plote afunction of 3 variables could be visualized as a 2D grid of 2D contours as this i.stack.imgur.com/QRjO6.png $\endgroup$ Jun 8 '17 at 22:28
  • $\begingroup$ @Emad: So PLEASE ANSWER: What is $c$?? $\endgroup$ Jun 8 '17 at 22:56
  • $\begingroup$ c representation a constant level set ...... we assume $f(x,y,z)=c$ where c is constant $\endgroup$ Jun 8 '17 at 23:01
  • $\begingroup$ @ David G. Stork Please see this question math.stackexchange.com/questions/1573755/… to understand me $\endgroup$ Jun 8 '17 at 23:06
3
$\begingroup$

This is for illustrative purposes. ContourPlot can be used for grid of graphics and SliceContourPlot3D for a 3D visualization. Noting the link to the provided graphic does not relate to provided function, the differences in plot are expected.

f[x_, y_, z_] := x z + y z - x y z
cp[c_, z0_] := 
 ContourPlot[f[x, y, z0] == c, {x, -4, 4}, {y, -4, 4}, 
  FrameLabel -> {Row[{"c=", c, ", z=", z0}], None}, BaseStyle -> 12]
Grid[Table[cp[i, j], {j, Range[-2, 2]}, {i, Range[-2, 2]}], 
 Frame -> All, Spacings -> {2, 0}]
g[x_, y_, z_, c_] := f[x, y, z] - c
scp[c_, z0_] := 
 SliceContourPlot3D[
  g[x, y, z, c], {z == z0}, {x, -4, 4}, {y, -4, 4}, {z, -4, 4}, 
  Contours -> {0}, ContourShading -> None, ContourStyle -> Thick]

enter image description here

enter image description here

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