ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 10 Sep 2018 11:08:47 -0500Plotting systems of linear equations with 3 variableshttp://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/ Hello,
Is there a way to plot these 3 equations in 3d space that would show them intersecting?
2x + 3y - z = 15,
x - 3y + 3z = -4,
4x - 3y - z = 19,
I can get the numerical answers, but I'd love to be able to show a graphical representation to students and myself.
Thank you,
Steve.
Here is the code for the numerical answers:
# 2*x + 3*y - z == 1
# x - 3y + 3z == - 4
# 4*x -3*y- z == 19
var('x,y,z')
words = solve([2*x + 3*y - z == 15, x - 3*y + 3*z == - 4,4*x -3*y- z == 19],x,y,z)
words
Wed, 05 Sep 2018 02:08:16 -0500http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/Comment by FrédéricC for <p>Hello,
Is there a way to plot these 3 equations in 3d space that would show them intersecting?
2x + 3y - z = 15,
x - 3y + 3z = -4,
4x - 3y - z = 19,</p>
<p>I can get the numerical answers, but I'd love to be able to show a graphical representation to students and myself.</p>
<p>Thank you,
Steve.</p>
<p>Here is the code for the numerical answers:</p>
<pre><code># 2*x + 3*y - z == 1
# x - 3y + 3z == - 4
# 4*x -3*y- z == 19
var('x,y,z')
words = solve([2*x + 3*y - z == 15, x - 3*y + 3*z == - 4,4*x -3*y- z == 19],x,y,z)
words
</code></pre>
http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43588#post-id-43588sage: HyperplaneArrangements?Wed, 05 Sep 2018 03:13:41 -0500http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43588#post-id-43588Answer by slelievre for <p>Hello,
Is there a way to plot these 3 equations in 3d space that would show them intersecting?
2x + 3y - z = 15,
x - 3y + 3z = -4,
4x - 3y - z = 19,</p>
<p>I can get the numerical answers, but I'd love to be able to show a graphical representation to students and myself.</p>
<p>Thank you,
Steve.</p>
<p>Here is the code for the numerical answers:</p>
<pre><code># 2*x + 3*y - z == 1
# x - 3y + 3z == - 4
# 4*x -3*y- z == 19
var('x,y,z')
words = solve([2*x + 3*y - z == 15, x - 3*y + 3*z == - 4,4*x -3*y- z == 19],x,y,z)
words
</code></pre>
http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?answer=43590#post-id-43590The way I understand the question, you would like to visualize the plane given
by each of the equations, and see whether they have a common intersection.
Here is one way to do that.
Define the three equations:
sage: x, y, z = SR.var('x y z')
sage: a, b, c = [2*x + 3*y - z == 15, x - 3*y + 3*z == -4, 4*x - 3*y - z == 19]
and the range of x, y, z where you want to plot:
sage: xx = (x, -10, 10)
sage: yy = (y, -10, 10)
sage: zz = (z, -10, 10)
Define the plots of the three planes, with different colors:
sage: pa = implicit_plot3d(a, xx, yy, zz, color='blue', alpha=0.3)
sage: pb = implicit_plot3d(b, xx, yy, zz, color='red', alpha=0.3)
sage: pc = implicit_plot3d(c, xx, yy, zz, color='green', alpha=0.3)
sage: p = a + b + c
Then you can show the combined plot using various viewers:
sage: p.show(aspect_ratio=1, viewer='jmol')
Launched jmol viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='threejs')
Launched html viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='tachyon')
Launched png viewer for Graphics3d Object
It seems that the threejs viewer does not take into account
the opacity setting given by the alpha option.
In the "SageNB" notebook you have an extra viewer available:
sage: p.show(aspect_ratio=1, viewer='canvas3d')
Launched png viewer for Graphics3d Object
Wed, 05 Sep 2018 03:59:59 -0500http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?answer=43590#post-id-43590Comment by slelievre for <p>The way I understand the question, you would like to visualize the plane given
by each of the equations, and see whether they have a common intersection.</p>
<p>Here is one way to do that.</p>
<p>Define the three equations:</p>
<pre><code>sage: x, y, z = SR.var('x y z')
sage: a, b, c = [2*x + 3*y - z == 15, x - 3*y + 3*z == -4, 4*x - 3*y - z == 19]
</code></pre>
<p>and the range of x, y, z where you want to plot:</p>
<pre><code>sage: xx = (x, -10, 10)
sage: yy = (y, -10, 10)
sage: zz = (z, -10, 10)
</code></pre>
<p>Define the plots of the three planes, with different colors:</p>
<pre><code>sage: pa = implicit_plot3d(a, xx, yy, zz, color='blue', alpha=0.3)
sage: pb = implicit_plot3d(b, xx, yy, zz, color='red', alpha=0.3)
sage: pc = implicit_plot3d(c, xx, yy, zz, color='green', alpha=0.3)
sage: p = a + b + c
</code></pre>
<p>Then you can show the combined plot using various viewers:</p>
<pre><code>sage: p.show(aspect_ratio=1, viewer='jmol')
Launched jmol viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='threejs')
Launched html viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='tachyon')
Launched png viewer for Graphics3d Object
</code></pre>
<p>It seems that the threejs viewer does not take into account
the opacity setting given by the alpha option.</p>
<p>In the "SageNB" notebook you have an extra viewer available:</p>
<pre><code>sage: p.show(aspect_ratio=1, viewer='canvas3d')
Launched png viewer for Graphics3d Object
</code></pre>
http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43634#post-id-43634No worries. We have a system of three equations:
- (a) $2x + 3y - z = 15$
- (b) $x - 3y + 3z = -4$
- (c) $4x - 3y - z = 19$
Starting from this system, there are
- three interesting planes:
- the solutions to (a) form a plane;
- the solutions to (b) form a plane;
- the solutions to (c) form a plane;
- three interesting lines:
- the common solutions to (a) and (b) form a line;
- the common solutions to (b) and (c) form a line;
- the common solutions to (a) and (c) form a line;
- one interesting point:
- the common solutions to (a), (b) and (c) consist in a single point.
One might be interested in representing these three lines too.Mon, 10 Sep 2018 11:08:47 -0500http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43634#post-id-43634Comment by SteveF for <p>The way I understand the question, you would like to visualize the plane given
by each of the equations, and see whether they have a common intersection.</p>
<p>Here is one way to do that.</p>
<p>Define the three equations:</p>
<pre><code>sage: x, y, z = SR.var('x y z')
sage: a, b, c = [2*x + 3*y - z == 15, x - 3*y + 3*z == -4, 4*x - 3*y - z == 19]
</code></pre>
<p>and the range of x, y, z where you want to plot:</p>
<pre><code>sage: xx = (x, -10, 10)
sage: yy = (y, -10, 10)
sage: zz = (z, -10, 10)
</code></pre>
<p>Define the plots of the three planes, with different colors:</p>
<pre><code>sage: pa = implicit_plot3d(a, xx, yy, zz, color='blue', alpha=0.3)
sage: pb = implicit_plot3d(b, xx, yy, zz, color='red', alpha=0.3)
sage: pc = implicit_plot3d(c, xx, yy, zz, color='green', alpha=0.3)
sage: p = a + b + c
</code></pre>
<p>Then you can show the combined plot using various viewers:</p>
<pre><code>sage: p.show(aspect_ratio=1, viewer='jmol')
Launched jmol viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='threejs')
Launched html viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='tachyon')
Launched png viewer for Graphics3d Object
</code></pre>
<p>It seems that the threejs viewer does not take into account
the opacity setting given by the alpha option.</p>
<p>In the "SageNB" notebook you have an extra viewer available:</p>
<pre><code>sage: p.show(aspect_ratio=1, viewer='canvas3d')
Launched png viewer for Graphics3d Object
</code></pre>
http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43631#post-id-43631Hello,
You are correct. In my mind, I was looking for 3 lines, but mathematically those equations produce planes. Maybe I was trying to relate to 2 variable linear equations Please excuse my ignorance.
Thank you,
Steve.Mon, 10 Sep 2018 00:20:35 -0500http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43631#post-id-43631Comment by slelievre for <p>The way I understand the question, you would like to visualize the plane given
by each of the equations, and see whether they have a common intersection.</p>
<p>Here is one way to do that.</p>
<p>Define the three equations:</p>
<pre><code>sage: x, y, z = SR.var('x y z')
sage: a, b, c = [2*x + 3*y - z == 15, x - 3*y + 3*z == -4, 4*x - 3*y - z == 19]
</code></pre>
<p>and the range of x, y, z where you want to plot:</p>
<pre><code>sage: xx = (x, -10, 10)
sage: yy = (y, -10, 10)
sage: zz = (z, -10, 10)
</code></pre>
<p>Define the plots of the three planes, with different colors:</p>
<pre><code>sage: pa = implicit_plot3d(a, xx, yy, zz, color='blue', alpha=0.3)
sage: pb = implicit_plot3d(b, xx, yy, zz, color='red', alpha=0.3)
sage: pc = implicit_plot3d(c, xx, yy, zz, color='green', alpha=0.3)
sage: p = a + b + c
</code></pre>
<p>Then you can show the combined plot using various viewers:</p>
<pre><code>sage: p.show(aspect_ratio=1, viewer='jmol')
Launched jmol viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='threejs')
Launched html viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='tachyon')
Launched png viewer for Graphics3d Object
</code></pre>
<p>It seems that the threejs viewer does not take into account
the opacity setting given by the alpha option.</p>
<p>In the "SageNB" notebook you have an extra viewer available:</p>
<pre><code>sage: p.show(aspect_ratio=1, viewer='canvas3d')
Launched png viewer for Graphics3d Object
</code></pre>
http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43627#post-id-43627@SteveF: one thing to understand is that:
- the solutions to the equation $2x + 3y - z = 15$ form a plane (not a line),
- the solutions to the equation $x - 3y + 3z = -4$ form a plane (not a line),
- the solutions to the equation $4x - 3y - z = 19$ form a plane (not a line).
In your drawing, what are the three colored lines?Sun, 09 Sep 2018 17:18:48 -0500http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43627#post-id-43627Comment by SteveF for <p>The way I understand the question, you would like to visualize the plane given
by each of the equations, and see whether they have a common intersection.</p>
<p>Here is one way to do that.</p>
<p>Define the three equations:</p>
<pre><code>sage: x, y, z = SR.var('x y z')
sage: a, b, c = [2*x + 3*y - z == 15, x - 3*y + 3*z == -4, 4*x - 3*y - z == 19]
</code></pre>
<p>and the range of x, y, z where you want to plot:</p>
<pre><code>sage: xx = (x, -10, 10)
sage: yy = (y, -10, 10)
sage: zz = (z, -10, 10)
</code></pre>
<p>Define the plots of the three planes, with different colors:</p>
<pre><code>sage: pa = implicit_plot3d(a, xx, yy, zz, color='blue', alpha=0.3)
sage: pb = implicit_plot3d(b, xx, yy, zz, color='red', alpha=0.3)
sage: pc = implicit_plot3d(c, xx, yy, zz, color='green', alpha=0.3)
sage: p = a + b + c
</code></pre>
<p>Then you can show the combined plot using various viewers:</p>
<pre><code>sage: p.show(aspect_ratio=1, viewer='jmol')
Launched jmol viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='threejs')
Launched html viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='tachyon')
Launched png viewer for Graphics3d Object
</code></pre>
<p>It seems that the threejs viewer does not take into account
the opacity setting given by the alpha option.</p>
<p>In the "SageNB" notebook you have an extra viewer available:</p>
<pre><code>sage: p.show(aspect_ratio=1, viewer='canvas3d')
Launched png viewer for Graphics3d Object
</code></pre>
http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43608#post-id-43608Thank you for your patience and help.
The goal is to create and image like the one at this link ( [3d Image](https://docs.google.com/document/d/144qJ5yhrnc3W2O7zZNrHVpt-XVM7-RXtbrTMyNPHTrQ/edit?usp=sharing) so I can show a classroom of middle school and/or high school students what the solution to a system of linear equations that has 3 variables looks like. This abstraction can be very hard for students and me too.Thu, 06 Sep 2018 23:13:37 -0500http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43608#post-id-43608Comment by slelievre for <p>The way I understand the question, you would like to visualize the plane given
by each of the equations, and see whether they have a common intersection.</p>
<p>Here is one way to do that.</p>
<p>Define the three equations:</p>
<pre><code>sage: x, y, z = SR.var('x y z')
sage: a, b, c = [2*x + 3*y - z == 15, x - 3*y + 3*z == -4, 4*x - 3*y - z == 19]
</code></pre>
<p>and the range of x, y, z where you want to plot:</p>
<pre><code>sage: xx = (x, -10, 10)
sage: yy = (y, -10, 10)
sage: zz = (z, -10, 10)
</code></pre>
<p>Define the plots of the three planes, with different colors:</p>
<pre><code>sage: pa = implicit_plot3d(a, xx, yy, zz, color='blue', alpha=0.3)
sage: pb = implicit_plot3d(b, xx, yy, zz, color='red', alpha=0.3)
sage: pc = implicit_plot3d(c, xx, yy, zz, color='green', alpha=0.3)
sage: p = a + b + c
</code></pre>
<p>Then you can show the combined plot using various viewers:</p>
<pre><code>sage: p.show(aspect_ratio=1, viewer='jmol')
Launched jmol viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='threejs')
Launched html viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='tachyon')
Launched png viewer for Graphics3d Object
</code></pre>
<p>It seems that the threejs viewer does not take into account
the opacity setting given by the alpha option.</p>
<p>In the "SageNB" notebook you have an extra viewer available:</p>
<pre><code>sage: p.show(aspect_ratio=1, viewer='canvas3d')
Launched png viewer for Graphics3d Object
</code></pre>
http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43597#post-id-43597Taken one by one, each of the equations in your system have a set of solutions
which is a plane (in the same way that if you say $z = 0$, the solution set is
the whole $xy$-plane at altitude zero, so $x$ and $y$ can take any value).
If you take the equations two by two, then you get three lines: if some triple
$(x, y, z)$ satisfies both (a) and (b), the corresponding point is both in
plane (a) and plane (b), so it lies on the line which is the intersection of
these planes. So, (a) and (b) give a line, (b) and (c) give another one, and
(c) and (a) give a third one. Are those the lines you wanted to plot?Thu, 06 Sep 2018 02:52:26 -0500http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43597#post-id-43597Comment by SteveF for <p>The way I understand the question, you would like to visualize the plane given
by each of the equations, and see whether they have a common intersection.</p>
<p>Here is one way to do that.</p>
<p>Define the three equations:</p>
<pre><code>sage: x, y, z = SR.var('x y z')
sage: a, b, c = [2*x + 3*y - z == 15, x - 3*y + 3*z == -4, 4*x - 3*y - z == 19]
</code></pre>
<p>and the range of x, y, z where you want to plot:</p>
<pre><code>sage: xx = (x, -10, 10)
sage: yy = (y, -10, 10)
sage: zz = (z, -10, 10)
</code></pre>
<p>Define the plots of the three planes, with different colors:</p>
<pre><code>sage: pa = implicit_plot3d(a, xx, yy, zz, color='blue', alpha=0.3)
sage: pb = implicit_plot3d(b, xx, yy, zz, color='red', alpha=0.3)
sage: pc = implicit_plot3d(c, xx, yy, zz, color='green', alpha=0.3)
sage: p = a + b + c
</code></pre>
<p>Then you can show the combined plot using various viewers:</p>
<pre><code>sage: p.show(aspect_ratio=1, viewer='jmol')
Launched jmol viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='threejs')
Launched html viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='tachyon')
Launched png viewer for Graphics3d Object
</code></pre>
<p>It seems that the threejs viewer does not take into account
the opacity setting given by the alpha option.</p>
<p>In the "SageNB" notebook you have an extra viewer available:</p>
<pre><code>sage: p.show(aspect_ratio=1, viewer='canvas3d')
Launched png viewer for Graphics3d Object
</code></pre>
http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43595#post-id-43595Hello, Thank you. That helped. What I was hoping to do was to have 3 distinct lines (or curves) rather than planes. The code did work though. I'm not familiar with viewers.
x, y, z = SR.var('x y z')
a, b, c = [2*x + 3*y - z == 15, x - 3*y + 3*z == -4, 4*x - 3*y - z == 19]
xx = (x, -10, 10)
yy = (y, -10, 10)
zz = (z, -10, 10)
pa = implicit_plot3d(a, xx, yy, zz, color='blue', alpha=0.3)
pb = implicit_plot3d(b, xx, yy, zz, color='red', alpha=0.3)
pc = implicit_plot3d(c, xx, yy, zz, color='green', alpha=0.3)
p = a + b + c
show(pa + pb + pc)Thu, 06 Sep 2018 00:58:43 -0500http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43595#post-id-43595Comment by eric_g for <p>The way I understand the question, you would like to visualize the plane given
by each of the equations, and see whether they have a common intersection.</p>
<p>Here is one way to do that.</p>
<p>Define the three equations:</p>
<pre><code>sage: x, y, z = SR.var('x y z')
sage: a, b, c = [2*x + 3*y - z == 15, x - 3*y + 3*z == -4, 4*x - 3*y - z == 19]
</code></pre>
<p>and the range of x, y, z where you want to plot:</p>
<pre><code>sage: xx = (x, -10, 10)
sage: yy = (y, -10, 10)
sage: zz = (z, -10, 10)
</code></pre>
<p>Define the plots of the three planes, with different colors:</p>
<pre><code>sage: pa = implicit_plot3d(a, xx, yy, zz, color='blue', alpha=0.3)
sage: pb = implicit_plot3d(b, xx, yy, zz, color='red', alpha=0.3)
sage: pc = implicit_plot3d(c, xx, yy, zz, color='green', alpha=0.3)
sage: p = a + b + c
</code></pre>
<p>Then you can show the combined plot using various viewers:</p>
<pre><code>sage: p.show(aspect_ratio=1, viewer='jmol')
Launched jmol viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='threejs')
Launched html viewer for Graphics3d Object
sage: p.show(aspect_ratio=1, viewer='tachyon')
Launched png viewer for Graphics3d Object
</code></pre>
<p>It seems that the threejs viewer does not take into account
the opacity setting given by the alpha option.</p>
<p>In the "SageNB" notebook you have an extra viewer available:</p>
<pre><code>sage: p.show(aspect_ratio=1, viewer='canvas3d')
Launched png viewer for Graphics3d Object
</code></pre>
http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43591#post-id-43591For the `threejs` viewer, you can use the argument `opacity`, i.e. replace `alpha=0.3` by `opacity=0.3` in `implicit_plot3d`; see the [list of threejs options](http://doc.sagemath.org/html/en/reference/plot3d/threejs.html).Wed, 05 Sep 2018 05:03:22 -0500http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43591#post-id-43591Answer by pizza for <p>Hello,
Is there a way to plot these 3 equations in 3d space that would show them intersecting?
2x + 3y - z = 15,
x - 3y + 3z = -4,
4x - 3y - z = 19,</p>
<p>I can get the numerical answers, but I'd love to be able to show a graphical representation to students and myself.</p>
<p>Thank you,
Steve.</p>
<p>Here is the code for the numerical answers:</p>
<pre><code># 2*x + 3*y - z == 1
# x - 3y + 3z == - 4
# 4*x -3*y- z == 19
var('x,y,z')
words = solve([2*x + 3*y - z == 15, x - 3*y + 3*z == - 4,4*x -3*y- z == 19],x,y,z)
words
</code></pre>
http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?answer=43587#post-id-43587I think making a list of your points and then plotting point3d(L) would do. point3d(L) is useful to me, I think it would do what you want?
In addition to my answer, I would like to say that viewers such as jmol, tachyon, etc. can show your plot.
For some information about hyper arrangements, this link helps too.
I search on the Internet and found this handy.
*doc.sagemath.org/html/.../hyperplane_arrangement/arrangement.html*
If you find using sage a bit hard ( I guess you won't!) you can try GeoGebra.Wed, 05 Sep 2018 03:03:24 -0500http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?answer=43587#post-id-43587Comment by SteveF for <p>I think making a list of your points and then plotting point3d(L) would do. point3d(L) is useful to me, I think it would do what you want?</p>
<p>In addition to my answer, I would like to say that viewers such as jmol, tachyon, etc. can show your plot.</p>
<p>For some information about hyper arrangements, this link helps too.
I search on the Internet and found this handy.</p>
<p><em>doc.sagemath.org/html/.../hyperplane_arrangement/arrangement.html</em></p>
<p>If you find using sage a bit hard ( I guess you won't!) you can try GeoGebra.</p>
http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43596#post-id-43596Hello, Thank you for responding. Can you point me to a resource that shows how to create a list of points. And then another resource that shows how to plot with point3d(L)?
I use SageCell.
Thank you.Thu, 06 Sep 2018 01:14:42 -0500http://ask.sagemath.org/question/43586/plotting-systems-of-linear-equations-with-3-variables/?comment=43596#post-id-43596