Ask Your Question
1

Plotting systems of linear equations with 3 variables

asked 2018-09-05 09:08:16 +0100

SteveF gravatar image

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 flag offensive close merge delete

Comments

sage: HyperplaneArrangements?

FrédéricC gravatar imageFrédéricC ( 2018-09-05 10:13:41 +0100 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2018-09-05 10:59:59 +0100

slelievre gravatar image

updated 2023-01-19 16:47:09 +0100

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 = pa + pb + pc

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
edit flag offensive delete link more

Comments

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.

eric_g gravatar imageeric_g ( 2018-09-05 12:03:22 +0100 )edit

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)
SteveF gravatar imageSteveF ( 2018-09-06 07:58:43 +0100 )edit

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?

slelievre gravatar imageslelievre ( 2018-09-06 09:52:26 +0100 )edit

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 gravatar imageSteveF ( 2018-09-07 06:13:37 +0100 )edit

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

slelievre gravatar imageslelievre ( 2018-09-10 00:18:48 +0100 )edit
0

answered 2018-09-05 10:03:24 +0100

pizza gravatar image

updated 2018-09-05 11:11:56 +0100

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.

edit flag offensive delete link more

Comments

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.

SteveF gravatar imageSteveF ( 2018-09-06 08:14:42 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-09-05 09:08:16 +0100

Seen: 1,568 times

Last updated: Jan 19 '23