# How to plot a surface from a system of equations? [duplicate]

It seems like a natural thing to do, however I can't seem to find anything on the docs nor here on SE.

What I'd like to plot is the locus of solutions to a system of (polynomial) equations, e.g. $$\begin{cases}x=yz\\ y^2=xz\end{cases}$$.

I tried with with the command

ContourPlot3D[{x == y*z, y^2 == x*z}, {x, -10, 10}, {y, -10, 10}, {z, -10, 10}]


However I get the two plots of each equation, which is not what I want:

Basically, I'd like to see just the intersection.

What is the easiest way to do that?

## marked as duplicate by xzczd, Community♦May 18 at 10:04

• I made a thousand edits because the editor didn't let me publish the question, it kept complaining around missing code fences except there already were code fences. – mattecapu May 17 at 16:25

You can "plot" one equation as a contour and draw the mesh lines of the other equation onto it by using the option MeshFunctions.

curve = ContourPlot3D[
y^2 == x z
{x, -10, 10}, {y, -10, 10}, {z, -10, 10},
MeshFunctions -> Function[{x, y, z}, x - y z],
Mesh -> {{0}},
ContourStyle -> None,
BoundaryStyle -> None,
MeshStyle -> Thick,
PlotPoints -> 100
]


Here is also a compined plot that looks a bit more fancy:

surf = ContourPlot3D[{y^2 == x z, x == y z}, {x, -10, 10}, {y, -10, 10}, {z, -10, 10}, ContourStyle -> Opacity[0.4]];
Show[
surf,
curve /. Line[x__] :> {Lighter@Black, Specularity[White, 30],
Tube[x, 0.2]},
Lighting -> "Neutral"
]


• ugly yet effective... thanks! to the future me: Mesh-> {{0}} selects the level set $=0$ for the specified mesh function, the rest of the options is to remove stuff we don't want to see – mattecapu May 17 at 16:36
• Exactly. You got it. – Henrik Schumacher May 17 at 16:37

Define an implicit region with your equations by And-combining them:

ir = ImplicitRegion[x == y*z && y^2 == x*z, {x, y, z}];


Make a 3D plot by discretizing the implicit region:

DiscretizeRegion[ir, 3*{{-1, 1}, {-1, 1}, {-1, 1}},
MaxCellMeasure -> 10^-4, Boxed -> True, Axes -> True]


• Wow, I am surprised that DiscretizeRegion works so well on this! It used to produce quite shabby results for lower-dimensional regions... – Henrik Schumacher May 17 at 20:17
• @HenrikSchumacher you still need a massive dose of MaxCellMeasure to make it pretty. – Roman May 17 at 20:24