ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 17 May 2016 17:32:27 +0200Plot the intersection of two surfaces (or solutions of a system of eqs)https://ask.sagemath.org/question/33418/plot-the-intersection-of-two-surfaces-or-solutions-of-a-system-of-eqs/ 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?
Thanks in advanceMon, 16 May 2016 18:03:59 +0200https://ask.sagemath.org/question/33418/plot-the-intersection-of-two-surfaces-or-solutions-of-a-system-of-eqs/Answer by B r u n o for <p>Hi everybody,</p>
<p>I'd like to plot the solutions of the system</p>
<p>$$(X + Y )(X − Z^3)=0,$$</p>
<p>$$XY + Y^2=0.$$</p>
<p>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?</p>
<p>Thanks in advance</p>
https://ask.sagemath.org/question/33418/plot-the-intersection-of-two-surfaces-or-solutions-of-a-system-of-eqs/?answer=33426#post-id-33426Here 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]]
Tue, 17 May 2016 11:58:33 +0200https://ask.sagemath.org/question/33418/plot-the-intersection-of-two-surfaces-or-solutions-of-a-system-of-eqs/?answer=33426#post-id-33426Comment by Minkowski for <p>Here is a partial answer (I hope somebody can come with a better one!):</p>
<p>Plotting the solutions of an equation in $\mathbb R^3$ can be done using the method <code>implicit_plot3d</code>. So you can visualize the solutions of both equations as follows:</p>
<pre><code>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]
</code></pre>
<p>You can also visualize both solution sets together:</p>
<pre><code>sage: show(s1+s2)
</code></pre>
<p>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 <strong>in principle</strong> you could do</p>
<pre><code>sage: implicit_plot3d(((x+y)*(x-z^3))^2+(x*y+y^2)^2, (x,-2,2),(y,-2,2), (z,-2,2))
</code></pre>
<p>But the problem is that if you try this you will see an empty set of solutions. I am not sure about the reason.</p>
<p>Finally, even though it is not visualization, note that you can have also the set of solutions using solve:</p>
<pre><code>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]]
</code></pre>
https://ask.sagemath.org/question/33418/plot-the-intersection-of-two-surfaces-or-solutions-of-a-system-of-eqs/?comment=33427#post-id-33427Thank 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?Tue, 17 May 2016 13:08:53 +0200https://ask.sagemath.org/question/33418/plot-the-intersection-of-two-surfaces-or-solutions-of-a-system-of-eqs/?comment=33427#post-id-33427Answer by Minkowski for <p>Hi everybody,</p>
<p>I'd like to plot the solutions of the system</p>
<p>$$(X + Y )(X − Z^3)=0,$$</p>
<p>$$XY + Y^2=0.$$</p>
<p>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?</p>
<p>Thanks in advance</p>
https://ask.sagemath.org/question/33418/plot-the-intersection-of-two-surfaces-or-solutions-of-a-system-of-eqs/?answer=33431#post-id-33431 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)$. Tue, 17 May 2016 17:32:27 +0200https://ask.sagemath.org/question/33418/plot-the-intersection-of-two-surfaces-or-solutions-of-a-system-of-eqs/?answer=33431#post-id-33431Answer by calc314 for <p>Hi everybody,</p>
<p>I'd like to plot the solutions of the system</p>
<p>$$(X + Y )(X − Z^3)=0,$$</p>
<p>$$XY + Y^2=0.$$</p>
<p>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?</p>
<p>Thanks in advance</p>
https://ask.sagemath.org/question/33418/plot-the-intersection-of-two-surfaces-or-solutions-of-a-system-of-eqs/?answer=33429#post-id-33429 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)
Tue, 17 May 2016 15:12:03 +0200https://ask.sagemath.org/question/33418/plot-the-intersection-of-two-surfaces-or-solutions-of-a-system-of-eqs/?answer=33429#post-id-33429