# ContourPlot3D with strange artifact

The following:

ContourPlot3D[Sqrt[1 - x^2 - y^2] - z == 0, {x, -1, 1}, {y, -1, 1}, {z, 0, 1}]


produces an ugly wall around the half sphere.

Is there some kind of option that can rid of it?

1. Switching to Surd[] did not help.
2. I know that there are many other ways of plotting the top half of a sphere, but I am working with ContourPlot3D[] for other reasons, and would like to continue to use it.
3. I noticed that with the constraint (the first argument) as: z == Sqrt[1 - x^2 - y^2], the offending artifact disappears. (However, as I am working with many types of constraints, I will not necessarily be able to isolate z each time.) What is the big difference in these two constraints??

Thank you.

• For reference, running ContourPlot3D on Sqrt[1-x^2-y^2]==z yields the wall artifact while running z==Sqrt[1-x^2-y^2] gives a much nicer plot (although with some artifacts around the edges) on MMA 12.1.1 on macOS. I think this behavior is undesirable, if not an outright bug. – Sami Jun 21 '20 at 10:03
• Thanx for that extra case. – Aharon Naiman Jun 21 '20 at 10:35
• How about ContourPlot3D[1 - x^2 - y^2 == z^2, {x, -1, 1}, {y, -1, 1}, {z, 0, 1}]? Your range already limits it to the positive $z$. – MarcoB Jun 21 '20 at 18:04

produces an ugly wall around the half sphere.

Just use the first solution ?

sol[x_, y_] := First[Sqrt[1 - x^2 - y^2]]
ContourPlot3D[Evaluate[z == sol[x, y]], {x, -1, 1}, {y, -1, 1}, {z, 0, 1}]


The wall was the second solution which you did not want.

• Thank you, I see now that the artifact is coming from a separate solution. However, 1) I mentioned that I cannot depend on being able to isolate z each time. 2) With the ?NumericQ qualifier, I got lots of First::normal: Nonatomic expression expected at position 1 in First[0. +0.999714 I]. -- how did you avoid that? – Aharon Naiman Jun 21 '20 at 11:00
• @AharonNaiman sorry, I added the _?NumericQ later here in the post without testing. Simply remove them and it works OK. As far as not able to isolate z issue, well, z has 2 solutions in your example. And you did not want to see one of them. I am not sure how to solve this otherwise. You either keep all solutions, or filter out the ones you do not want to see? What else do you suggest one could do? – Nasser Jun 21 '20 at 11:15
• Thanx @Nasser, indeed I had removed the two ?NumericQs in order to run your example, thereby seeing the two solutions. Before you pointed out that it was due to the second solution, I was hoping that there might be some kind of Exclusions option to remove the edge of the half-sphere. – Aharon Naiman Jun 21 '20 at 13:06