5
$\begingroup$

How can I make a 3D plot of

$$(x^2+y^2-1)^2+(y^2+z^2-1)^2+(x^2+z^2-1)^2=0$$

Does the above equation describes the same region as

$$x^2+y^2\le 1\wedge y^2+z^2\le 1\wedge x^2+z^2\le 1$$

$\endgroup$
5
  • 1
    $\begingroup$ Do we have a canonical version that this one can be marked a duplicate of? I thought we did but I cannot find it. The problem is that it's not that obvious to a newbie how to get from implicit equation (usual math term) to ContourPlot. $\endgroup$
    – Szabolcs
    Commented Apr 11, 2015 at 16:27
  • 2
    $\begingroup$ @Szabolcs Here are a couple of candidates. 3D: 10710. 2D: 34668. But since this solution set is a finite set of points (one might call it a degenerate surface), using ContourPlot3D is not a solution. See ubpdqn's answer. $\endgroup$
    – Michael E2
    Commented Apr 11, 2015 at 19:26
  • $\begingroup$ @MichaelE2 You're right, I wasn't careful. $\endgroup$
    – Szabolcs
    Commented Apr 11, 2015 at 19:37
  • $\begingroup$ @Szabolcs Actually the OP's second formulation is the intersection of three solid cylinders, which is quite different. (This time, I was careless. I didn't even read it the first time.) $\endgroup$
    – Michael E2
    Commented Apr 11, 2015 at 19:44
  • $\begingroup$ @UnitedKingdom Since the second region is bounded by cylinders, you can get a good plot with ParametricPlot3D like this i.sstatic.net/hEL0u.png. Code dump here: chat.stackexchange.com/transcript/message/21045469#21045469 $\endgroup$
    – Michael E2
    Commented Apr 11, 2015 at 20:20

2 Answers 2

4
$\begingroup$

ContourPlot3D seems to do it

f = (x^2 + y^2 - 1)^2 + (y^2 + z^2 - 1)^2 + (x^2 + z^2 - 1)^2;
ContourPlot3D[f, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, 
  ContourStyle -> Opacity[1], Mesh -> None, Contours -> {1}]

Mathematica graphics

There are many other options you can try for this command. You can change the options for Contours Opacity, and Mesh, etc.

Update

Answer for comment:

RegionPlot3D[
  x^2 + y^2 <= 1 && y^2 + z^2 <= 1 && x^2 + z^2 <= 1, 
  {x, -2, 2}, {y, -2, 2}, {z, -2, 2}]

Mathematica graphics

$\endgroup$
4
  • $\begingroup$ Thanks,maybe is $x^2+y^2\le 1,y^2+z^2\le 1,x^2+z^2\le 1$ $\endgroup$ Commented Apr 11, 2015 at 6:24
  • $\begingroup$ @UnitedKingdom I updated the answer for your comment reply $\endgroup$
    – Nasser
    Commented Apr 11, 2015 at 7:03
  • $\begingroup$ It's very nice,Thank you $\endgroup$ Commented Apr 11, 2015 at 7:43
  • 3
    $\begingroup$ Why do you set contours at 1, when the equation in OP requires 0? $\endgroup$
    – LLlAMnYP
    Commented Apr 11, 2015 at 9:06
21
$\begingroup$

$(x^2+y^2-1)^2+(y^2+z^2-1)^2+(x^2+z^2-1)^2=0$

is satisfied by a set of points. This can be established:

f = (x^2 + y^2 - 1)^2 + (y^2 + z^2 - 1)^2 + (x^2 + z^2 - 1)^2;
FullSimplify[Reduce[f == 0, {x, y, z}, Reals]]
Reduce[x^2 + y^2 == 1 && z^2 + y^2 == 1 && x^2 + z^2 == 1, {x, y, z}]

i.e.

(x == -(1/Sqrt[2]) || x == 1/Sqrt[2]) && (y == -(1/Sqrt[2]) || 
   y == 1/Sqrt[2]) && (z == -(1/Sqrt[2]) || z == 1/Sqrt[2])

Note as expected the last 2 results are equivalent. f=0, is a set of 8 points (vertices of a cube). This is separate issue for surfaces of f=n that can be explored by ContourPlot3D.

This can be seen in many ways:

ir = ImplicitRegion[
  x^2 + y^2 == 1 && z^2 + y^2 == 1 && x^2 + z^2 == 1, {x, y, z}];
dr = DiscretizeRegion[ir]

enter image description here

This can be visualised by using ContourPLot3D (as alluded to by Nasser ) imagine the limiting process to contour value 0:

ContourPlot3D[f, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, 
 Contours -> {0.1, 0.2, 0.4}, 
 ContourStyle -> {Opacity[0.2], Opacity[0.2], Opacity[0.2]}, 
 Mesh -> False, PlotLegends -> Automatic]

enter image description here

Just another way to see this:

pts = Tuples[{-1/Sqrt[2], 1/Sqrt[2]}, 3];
Graphics3D[{Opacity[0.4], Cylinder[{{0, 0, -1}, {0, 0, 1}}, 1], 
  Cylinder[{{0, -1, 0}, {0, 1, 0}}, 1], 
  Cylinder[{{-1, 0, 0}, {1, 0, 0}}, 1],
  Sphere[{0, 0, 0}, Sqrt[3/2]],
  Opacity[1], PointSize[0.02], Red, Point[pts]}, Boxed -> False, 
 Background -> Black]

enter image description here

$\endgroup$

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