0
$\begingroup$

I am attempting to see the contour plot for the function, Sqrt[y-x]==z. The graph shows an odd structure that seems to fall where a vertical asymptote would exist. What can I do to eliminate the odd structure? Here is my code for it:

ContourPlot3D[Sqrt[y-x]==z,{x,-6,6},{y,0,6},{z,0,4}] 

and here is the result:

enter image description here

$\endgroup$
3
  • 3
    $\begingroup$ ContourPlot3D[Re[Sqrt[y - x]] == z, {x, -6, 6}, {y, 0, 6}, {z, 0, 4}, AxesLabel -> Automatic] $\endgroup$
    – Bob Hanlon
    Commented Dec 22, 2022 at 15:34
  • $\begingroup$ Thanks Bob. I am fairly new to Mathematica. I knew there was a real number issue just by what was going on in the graph. I was unaware that adding the Re would only allow real number output. This helps tremendously. $\endgroup$
    – GeorgeE
    Commented Dec 22, 2022 at 16:41
  • 1
    $\begingroup$ @BobHanlon ContourPlot3D[Re[Sqrt[y - x]] == z, {x, -6, 6}, {y, 0, 6}, {z, -4, 4}, AxesLabel -> Automatic] will get the wrong result. The result contain a part of z==0 and y<=x. $\endgroup$
    – cvgmt
    Commented Dec 23, 2022 at 1:42

1 Answer 1

4
$\begingroup$

It is a bug.

we have to remove Sqrt from the original equation.

ContourPlot3D[y - x == z^2, {x, -6, 6}, {y, 0, 6}, {z, 0, 4}]

Or

ContourPlot3D[y - x == z^2, {x, -6, 6}, {y, 0, 6}, {z, -4, 4}, 
 RegionFunction -> Function[{x, y, z}, z >= 0], 
 RegionBoundaryStyle -> None]

enter image description here

Or use ImplicitRegion, still avoid Sqrt.

reg = ImplicitRegion[{y - x == z^2, 
   z >= 0}, {{x, -6, 6}, {y, 0, 6}, {z, -4, 4}}]
RegionPlot3D[DiscretizeRegion@reg, Axes -> True, BoxRatios -> 1, 
 Mesh -> 10]

enter image description here

$\endgroup$
2
  • $\begingroup$ I must have accidently hit a downvote a day or so ago from my iPhone . I just now corrected it to an upvote. Sorry about that. $\endgroup$
    – JimB
    Commented Dec 24, 2022 at 0:37
  • $\begingroup$ @JimB Thanks :) $\endgroup$
    – cvgmt
    Commented Dec 24, 2022 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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