# 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

edit retag close merge delete

Sort by » oldest newest most voted

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.

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

more

For 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.

Hello, 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)


Taken 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?

Thank you for your patience and help.

The goal is to create and image like the one at this link ( 3d Image 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.

@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?

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?

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.

more

Hello, 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.