Plot a 3D figure with different colors of a System of three Equations using SageMath

asked 2024-02-19 15:28:10 +0200

MKS gravatar image

updated 2024-02-19 15:57:06 +0200

# Define variables
x, y, z = var('x,y,z')

# Define equations
eq1 = x + 2*y + 4*z == 7
eq2 = 3*x + 7*y + 2*z == -11
eq3 = 2*x + 3*y + 3*z == 1

# Plot each plane in a different color and label them
plane1 = implicit_plot3d(eq1, (x, -10, 10), (y, -10, 10), (z, -10, 10), color='blue')
plane2 = implicit_plot3d(eq2, (x, -10, 10), (y, -10, 10), (z, -10, 10), color='green')
plane3 = implicit_plot3d(eq3, (x, -10, 10), (y, -10, 10), (z, -10, 10), color='red')

# Label each plane with its equation using text3d
label1 = text3d("x + 2*y + 4*z == 7", (8, 5, 8), color='blue')
label2 = text3d("3*x + 7*y + 2*z == -11", (-8, -5, 8), color='green')
label3 = text3d("2*x + 3*y + 3*z == 1", (-8, 5, -8), color='red')

# Add arrows indicating the direction of the equations
arrow1 = arrow3d((1, 3, 2), (2, 3, 4), color='blue')
arrow2 = arrow3d((-2, -3, 2), (-3, -4, -2), color='green')
arrow3 = arrow3d((1, 1, -2), (1, 2, -3), color='red')

# Show the plots
show(plane1 + plane2 + plane3 + label1 + label2 + label3 + arrow1 + arrow2 + arrow3)

Output: image description

edit retag flag offensive close merge delete

Comments

What is your bloody question ?

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-02-19 20:10:18 +0200 )edit