213 - A1 - Linear Equations

200 days ago by Professor213

Basic Linear Equations

John Travis

Mississippi College

Roughly, a linear equation is an expression where all of the variable terms are raised to the first power and not multiplied by other variable terms.  You are familiar with the standard equation for a line $y = mx + b$ and that is indeed a linear equation.  However, linear equations can contain many variables--and not just the x and y from your long forgotten past.  To keep things straight when you may have a number of variables, we often will denote the variables in a sequence format $x_1, x_2, ... , x_n$ which yields a more general form for a linear equation:

$a_1 x_1 + a_2 x_2 + a_3 x_3 + ... + a_n x_n = b$

where the terms $a_j$ are constant parameters known as the coefficients.  Of course, if you have more than one equation to deal with at a time, you will need some way to denote each one.  If each equation uses the same variables, the only thing that has to be changed is the collection of coefficients.  So, for each coefficient we add another subscript $a_{i,j}$ where the index "i" denotes the equation number and the second index "j" denotes which variable to associate with the value.  So, a more general way of referring to a linear equation is

$a_{i,1} x_1 + a_{i,2} x_2 + a_{i,3} x_3 + ... a_{i,n} x_n = b_i$

 

2D

In two dimensions, since there are so few terms to deal with, we often resort to using the old fashioned variables $x$ and $y$ versus $x_1$ and $x_2$.   To make things easier in 2D, we also may write the coefficients without subscripts in the form  ax + by = c. 

Regardless of the form of the equation, you can graph a line by plotting points or using point/slope ideas like you have done many times in your life.  In the box below, play around with the coeffiicients to see how each affects the graph of the resulting line.

%hide %auto var('x,y') @interact def _(a1=slider(-5,5,1/4,0,label='$a_1$'),a2=slider(-5,5,1/4,1,label='$a_2$'),b=slider(-6,6,1,0)): pretty_print(html('$(%s)$'%str(a1)+'$x + (%s)$'%a2+'$y = %s$'%b)) implicit_plot(a1*x+a2*y==b,(x,-5,5),(y,-5,5),aspect_ratio=True).show(axes=true) 
       
$a_1$ 
$a_2$ 

Click to the left again to hide and once more to show the dynamic interactive window

Questions:

  • How does the sign and value of $a_1$ and $a_2$ affect the graph of the line?
  • How does changing the value of b affect the graph of the line?

You can graph two lines at the same time but will need to supply two sets of coefficients--one set for each line.  Below, go ahead and type in the equations for each line and be certain to write the equations using correct mathematical syntax explicitly using "*" for every necessary multiplication.  Also, use "= =" instead of a single equals.

var('x,y') @interact def _(eq1=(3*x+y==1),eq2=(6*x+2*y==2),auto_update=True): print 'If you change the equations above, press Enter to redo the graphs' P1=implicit_plot(eq1,(x,-5,5),(y,-5,5),aspect_ratio=True,linewidth=3) P2=implicit_plot(eq2,(x,-5,5),(y,-5,5),aspect_ratio=True,color='red') show(P1+P2,axes=true) 
       

Click to the left again to hide and once more to show the dynamic interactive window

%hide %auto var('x,y') @interact def _(eq1=(3*x+2*y==6),eq2=(3*x-2*y==6),auto_update=True): print 'If you change the equations above, press Enter to redo the graphs' P1=implicit_plot(eq1,(x,-5,5),(y,-5,5),aspect_ratio=True,linewidth=3) P2=implicit_plot(eq2,(x,-5,5),(y,-5,5),aspect_ratio=True,color='red') soln = solve([eq1,eq2],x,y,solution_dict=True,ring=RR) if soln==[]: print html("\nThese lines do not intersect.") show((P1+P2),axes=true) else: for value in soln: x0 = value[x] y0 = value[y] print html('\nThe lines intersect at ('+str(x0)+','+str(y0)+')') soln_pt = point2d((x0,y0),size=40,rgbcolor='red') show((P1+P2+soln_pt),axes=true) 
       
eq1 
eq2 
auto_update 

Click to the left again to hide and once more to show the dynamic interactive window

3D

You can also see the graphs of linear equations with three variables.  In this case, we sometimes also just use the variables x, y and z and write the equations ax + by + cz = d instead of $a_1 x_1 + a_2 x_2 + a_3 x_3 = b$.  Below, experiment with entering various linear equations with the three variables x, y and z using the same format as you did with the graphs above.  Notice what the resulting graphs of each equation look like and when and if they intersect.

# Linear equation in three variables var('x,y,z') @interact def _(eq1=(3*x+2*y-5*z==6),auto_update=True): P1=implicit_plot3d(eq1,(x,-5,5),(y,-5,5),(z,-5,5),aspect_ratio=True,color='red',axes='true') show(P1) 
       
eq1 
auto_update 

Click to the left again to hide and once more to show the dynamic interactive window

# Example with no solutions in 3D var('x,y,z') @interact def _(eq1=(3*x+2*y-5*z==6),eq2=(3*x-2*y==6),eq3=(3*x+6*y-10*z==13),auto_update=True): print 'If you change the equations above, press Enter to redo the graphs' P1=implicit_plot3d(eq1,(x,-5,5),(y,-5,5),(z,-5,5),aspect_ratio=True,color='red') P2=implicit_plot3d(eq2,(x,-5,5),(y,-5,5),(z,-5,5),aspect_ratio=True,color='green') P3=implicit_plot3d(eq3,(x,-5,5),(y,-5,5),(z,-5,5),aspect_ratio=True,color='blue') show(P1+P2+P3) 
       
eq1 
eq2 
eq3 
auto_update 

Click to the left again to hide and once more to show the dynamic interactive window

# Example with infinitely many in 3D var('x,y,z') @interact def _(eq1=(3*x+2*y-5*z==6),eq2=(3*x-2*y==6),eq3=(3*x+6*y-10*z==6),auto_update=True): print 'If you change the equations above, press Enter to redo the graphs' P1=implicit_plot3d(eq1,(x,-5,5),(y,-5,5),(z,-5,5),aspect_ratio=True,color='red') P2=implicit_plot3d(eq2,(x,-5,5),(y,-5,5),(z,-5,5),aspect_ratio=True,color='green') P3=implicit_plot3d(eq3,(x,-5,5),(y,-5,5),(z,-5,5),aspect_ratio=True,color='blue') show(P1+P2+P3) 
       
eq1 
eq2 
eq3 
auto_update 

Click to the left again to hide and once more to show the dynamic interactive window

%hide %auto var('x,y,z') @interact def _(eq1=(3*x+2*y-5*z==6),eq2=(3*x-2*y==6),eq3=(2*x+3*z==9),auto_update=True): print 'If you change the equations above, press Enter to redo the graphs' P1=implicit_plot3d(eq1,(x,-5,5),(y,-5,5),(z,-5,5),aspect_ratio=True,color='red') P2=implicit_plot3d(eq2,(x,-5,5),(y,-5,5),(z,-5,5),aspect_ratio=True,color='green') P3=implicit_plot3d(eq3,(x,-5,5),(y,-5,5),(z,-5,5),aspect_ratio=True,color='blue') # soln = solve([eq1,eq2,eq3],x,y,z,ring=RR) P = P1+P2+P3 soln = solve([eq1,eq2,eq3],x,y,z,solution_dict=True,ring=RR) if soln==[]: print html("\nThese planes do not intersect.") else: for value in soln: x0 = value[x] y0 = value[y] z0 = value[z] print html('\nThe planes intersect at ('+str(x0)+','+str(y0)+','+str(z0)+')') soln_pt = point3d((x0,y0,z0),size=20,rgbcolor='yellow') P += soln_pt show(P) 
       
eq1 
eq2 
eq3 
auto_update 

Click to the left again to hide and once more to show the dynamic interactive window

# Notice that symbolic mathematics software can sometimes deal with "parameters" var('x,y,z,a,b') eq1 = 4*x-y == a eq2 = -4*x-3*y-3*z == 1 eq3 = 5*x-3*y-2*z == -6 solns = solve([eq1,eq2,eq3],(x,y,z),ring=RR) show(eq1) show(eq2) show(eq3) show(solns) for soln in solns: show(soln) 
       

                                
                            

                                
# and there still might be a situation where there is no solution var('x,y,z,a,b') eq1 = 4*x-y == a eq2 = -4*x-3*y-3*z == 1 eq3 = 5*x-3*y-2*z == -6 eq4 = x - y == 0 solns = solve([eq1,eq2,eq3,eq4],(x,y,z),ring=RR) show(solns) for soln in solns: show(soln) 
       

                                
                            

                                

There are also "non-linear" equations that sometimes arise.  We will not deal with these in MAT 213 since it is a course in "Linear Algebra".  In general, solving non-linear systems of equations can be difficult even when you only have a few equations.  Sometimes however things work out and sometimes software can be useful.

# Non-linear solve. Note that approximations might be made if the system can't do it exactly. reset() var('x,y,z,a,b') eq1 = 4*x^2-y == 2 eq2 = -4*x*y == 1 eq3 = -2*z*y^3 == -6 pretty_print(eq1) pretty_print(eq2) pretty_print(eq3) pretty_print("has the following solutions:") solns = solve([eq1,eq2,eq3],(x,y,z),ring=RR,solution_dict=true) for soln in solns: show(soln) show(eq1(x=soln[x],y=soln[y],z=soln[z])) show(eq2(x=soln[x],y=soln[y],z=soln[z])) show(eq3(x=soln[x],y=soln[y],z=soln[z]))