# Plot the intersection of two surfaces (or solutions of a system of eqs)

asked 2016-05-16 18:03:59 +0200 This post is a wiki. Anyone with karma >750 is welcome to improve it.

Hi everybody,

I'd like to plot the solutions of the system

$$(X + Y )(X − Z^3)=0,$$

$$XY + Y^2=0.$$

in 3D, I mean, the set of points (X,Y,Z) in IR^3 that verify the system. I don't know how to do it. I was searching how to plot the intersection of both surfaces, but neither I could. ¿Could anyone tell me how to do it?

edit retag close merge delete

Sort by » oldest newest most voted

You can plot the solutions from the solve command by treating them as parametric equations for a surface and a line. Note that one of the solutions listed by solve is a subset of another of the solutions.

p=parametric_plot3d((r1,-r1,r2),(r1,-4,4),(r2,-2,2))
p+=parametric_plot3d((0,0,r3),(r3,-2,2),thickness=3)
p+=parametric_plot3d((r4^3,0,r4),(r4,-2,2),thickness=3)

more

Here is a partial answer (I hope somebody can come with a better one!):

Plotting the solutions of an equation in $\mathbb R^3$ can be done using the method implicit_plot3d. So you can visualize the solutions of both equations as follows:

sage: var('x,y,z')
sage: s1 = implicit_plot3d((x+y)*(x-z^3), (x,-2,2),(y,-2,2), (z,-2,2))
sage: s2 = implicit_plot3d(x*y+y^2, (x,-2,2),(y,-2,2), (z,-2,2), color="red")
sage: show(s1)
[solutions of the first equation]
sage: show(s2)
[solutions of the second equation]


You can also visualize both solution sets together:

sage: show(s1+s2)


Since you are looking for solutions in $\mathbb R^3$, having both equations equal zero is the same as the sum of their squares equal zero. So in principle you could do

sage: implicit_plot3d(((x+y)*(x-z^3))^2+(x*y+y^2)^2, (x,-2,2),(y,-2,2), (z,-2,2))


But the problem is that if you try this you will see an empty set of solutions. I am not sure about the reason.

Finally, even though it is not visualization, note that you can have also the set of solutions using solve:

sage: sol = solve([(x+y)*(x-z^3),x*y+y^2], [x,y,z])
sage: sol
[[x == r1, y == -r1, z == r2], [x == 0, y == 0, z == r3], [x == r4^3, y == 0, z == r4]]

more

Thank you very much! In order to see the intersection of the two surfaces, could I plot the solutions of the system, I mean, can "sol" be plotted?

Perfect! Thanks both of you. It can be seen perfecty. I needed to see the irreducible components of $\mathbb{C}[x,y,z]/((x+y)(x-z^2),xy+y^2)$.

more