# Cannot get plot of polynomial (x^2 + y^2 + z^2 - 4)^2 == 0 from ContourPlot3D [closed]

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.

• 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] – Jason B. Sep 14 '15 at 11:42
• 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 – Jason B. Sep 14 '15 at 11:49
• 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". – m_goldberg Sep 14 '15 at 12:03
• Closely related: 87805 – yohbs Sep 14 '15 at 21:51

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}] 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: 