2
$\begingroup$

I'm trying to make a 3D contour plot the polynomial equation

$$(x^2 + y^2 + z^2 - 4)^2 == 0, \quad \quad (1)$$

Without power 2

$$ (x^2 + y^2 + z^2 - 4) == 0, \quad \quad (2)$$

it plots a sphere with radius 2. With power 2 $(1)$ it plots an empty set.

My motivation is to 3D contour plot the polynomial equation

$$ (x^2 + y^2 + z^2 - 4)^2 + ((x - 1)^2 + y^2 - 1)^2 == 0, \quad \quad (3) $$

But the result is the same as in $(1)$. (Plotting this solution set might be even more tricky as it is not a surface, but a 3D curve;)

These polynomials don't seem to be very complex (max. deg. 4) and with some modification (as with adding +x) it plots.

I'm looking forward to any idea to fix that and so I can produce a 3D contour plot these polynomials.

$\endgroup$

closed as off-topic by m_goldberg, dr.blochwave, MarcoB, Sjoerd C. de Vries, Silvia Sep 14 '15 at 14:41

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, dr.blochwave, MarcoB, Sjoerd C. de Vries, Silvia
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Actually, no need to bring 3D plotting into it, the problem is still there in 2D. Compare the output of ContourPlot[(x^2 + y^2 - 4)^2, {x, -4, 4}, {y, -4, 4}, Contours -> {0}, ContourShading -> None] to ContourPlot[(x^2 + y^2 - 4), {x, -4, 4}, {y, -4, 4}, Contours -> {0}, ContourShading -> None] $\endgroup$ – Jason B. Sep 14 '15 at 11:42
  • 1
    $\begingroup$ One workaround would be to substitute a very small value for 0. This will give the approximate curve for the 2D case: ContourPlot[(x^2 + y^2 - 4)^2, {x, -4, 4}, {y, -4, 4}, Contours -> {0.001}, ContourShading -> None, PlotPoints -> 100] A similar thing works for the 3D case $\endgroup$ – Jason B. Sep 14 '15 at 11:49
  • 3
    $\begingroup$ Look at the last example under Examples > Possible Issues in the Document Center article for ContourPlot3D. You will find an example similar to yours with the statement, "For functions that are always non-negative, it is not possible to find the 0 contour". $\endgroup$ – m_goldberg Sep 14 '15 at 12:03
  • $\begingroup$ Closely related: 87805 $\endgroup$ – yohbs Sep 14 '15 at 21:51
3
$\begingroup$

As m_goldberg pointed out, the ContourPlot3D Help page says "For functions that are always non-negative, it is not possible to find the 0 contour". So you have two options: plot a very small contour, or solve the equation for one of the variables and plot the result as a function of the other two.

Here are both solutions for your original equation:

ContourPlot3D[(x^2 + y^2 + z^2 - 4)^2, {x, -2.5, 2.5}, {y, -2.5, 2.5}, 
  {z, -2.5, 2.5}, Contours -> {0.05}, PlotPoints -> 150]
soln = Solve[(x^2 + y^2 + z^2 - 4)^2 == 0, z];
Plot3D[z /. soln, {x, -2.5, 2.5}, {y, -2.5, 2.5}, 
BoxRatios -> {1, 1, 1}]

enter image description here

The first method seems to be more robust. Just adding in the +((x - 1)^2 + y^2 - 1)^2 to the function gives the following output:

enter image description here

$\endgroup$

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