Linear Algebra Powertool
Systems of Linear Equations
On Line Section 1.3
Based on a worksheet by Michael K. May, as revised by Russell Blyth
> restart: with(linalg): with(plots): with(plottools):
Warning, the protected names norm and trace have been redefined and unprotected
Warning, the name changecoords has been redefined
Warning, the name arrow has been redefined
Outline
This worksheet covers problems parallel to the ones in the On Line 1.3 section.
The basic objectives are:
Part 1: Visualizing linear systems in
.
Consider the system of equations:
>
eq1 := x + y = 3;
eq2 := x - y = -1;
It is a simple exercise from college algebra to solve the system, obtaining the solution {x=1, y=2}. However, in this class, we are not as interested in solving this simple problem as we arein setting up a framework of understanding that we can use to attack larger systems of linear equations. Nevertheless, it is worthwhile to note that Maple will solve the system with the solve command.
> solve({eq1,eq2});
The same solve command lets us solve a single equation for a specified variable. In particular, we can solve eq1 for y. We can get the answer either as an expression, or in equation form.
> solve(eq1,y);solve(eq1,{y});
We can also plot the system and see its solution.
> plot({solve(eq1,y),solve(eq2,y)},x=-5..5,y=-5..5);
It should be noted that if we add in extra equations that are linear combinations of the initial set, then we will get the same solution.
>
plot({solve(eq1,y),solve(eq2,y),solve(eq1-eq2,y),solve(2*eq1+eq2,y)},
x=-5..5,y=-5..5);
A system has one solution when all of the lines meet in a single point. To have more then one solution, all of the lines must meet together in at least two points. Since two points define a line, that would mean that the equations all define the same line. If we have only two lines in the system, the only way for there to be no solution is for the lines to be parallel.
>
eq3 := x + y = 3;
eq4 := 2*x + 2*y = 6;
solve({eq3,eq4});
plot({solve(eq3,y),solve(eq4,y)},x=-5..5,y=-5..5);
The two equations above describe the same line.
>
eq5 := x + y = 3;
eq6 := x + y = 1;
solve({eq5,eq6});
plot({solve(eq5,y),solve(eq6,y)},x=-5..5,y=-5..5);
Three or more lines can meet pairwise in distinct points.
Consider the following system:
>
eq7 := x + y = 4; eq8 := x - y = 2; eq9 := 2*x - y = 1;
plot({solve(eq7,y), solve(eq8,y), solve(eq9,y)}, x=-5..5, y=-5..5);
Any two lines meet, but the whole system has no solution.
Exercises:
1) Solve the system {2x-y=4, x+2y=-4} three ways, first with pen and paper using college algebra, then with the solve command using Maple, then graphically using Maple.
>
>
2) Attempt to solve the system {x+y=2, -x+y =2, 2x+y=-2} the same three ways.
>
>
Part2: Visualizing linear systems in
.
If we try the same approach to visualizing systems of linear equations in three unknowns, we run into a display problem.
>
eq10 := 2*x + 3*y + z = 2;
eq11 := 2*x + 4*y + 7*z =6;
eq12 := 3*x + 10*y + 5*z = 7;
solve({eq10,eq11,eq12});
>
plot3d({solve(eq10,z),solve(eq11,z),solve(eq12,z)},
x=-5..5,y=-5..5, view=-5..5, axes=boxed);
Simply put, when Maple graphs 3D objects, by default it uses a color scheme that is the same for all objects. Maple does this to make it easy to perceive depth in the 2D display of a 3D object. Unfortunately, it makes it difficult to see intersections. We have to create plots in different colors for each of the equations, and then display them together.
>
display({
plot3d(solve(eq10,z),x=-5..5, y=-5..5, color=red),
plot3d(solve(eq11,z),x=-5..5, y=-5..5, color=blue),
plot3d(solve(eq12,z),x=-5..5, y=-5..5, color=green)},
view=-5..5, axes=boxed);
The picture makes it clear that any two of these planes meet in a line and that all three planes meet in a single point. The solution to the system of equations is the set of points that are on all of the planes - in this case, a single point.
The code for the picture above is a lot to construct at this point of the course. Instead, let's define a procedure named showplanes that graphs a set of planes for us. (This procedure can be copied to other worksheets. Note that the list of colors has to be defined for the procedure to work.)
>
colors :=[red, green, blue, yellow, cyan, wheat, violet, gray]:
showplanes := (eqnlist,xrange,yrange,zrange) -> display(
{seq(plot3d(solve(op(i,eqnlist),z),x=xrange,y=yrange,color=colors[i]),
i=1..nops(eqnlist))},view=zrange,axes=boxed):
> showplanes({eq10, eq11, eq12},-5..5,-5..5,-5..5);
Once again, if we add in equations to the system that are linear combinations of equations already in the system, then we get the same solution.
> showplanes({eq10, eq11, eq12,8*eq10-eq12,2*eq11-3*eq12},-5..5,-5..5,-5..5);
Three planes can intersect along a line:
>
eq13 := x - 3*z = -3;
eq14 := 2*x + 2*y - z = -2;
eq15 := x + 2*y + 2*z = 1;
solve({eq13,eq14,eq15});
> showplanes({eq13, eq14, eq15},-5..5,-5..5,-5..5);
If a pair of planes are parallel, then any system containing equations for these planes will have no solution. Three planes can also meet pairwise in a collection of "parallel" lines:
>
eq16 := x - 3*z = -3;
eq17 := 2*x - 5*y - z = -2;
eq18 := x + 2*y - 5*z = 1;
solve({eq16,eq17,eq18});
>
> showplanes({eq16, eq17, eq18},-5..5,-5..5,-5..5);
Exercises:
3) Use the showplanes command to give a visual description of the solution to the system {2x-3y+2z=1, x-6y+z=2, -x-3y-z=1}
>
4) Use the showplanes command to explain why the system {x+y+z=2, -x+y+z =3, 2x+y+z=-2} has no solution. Use pencil and paper to reach the same result symbolically.
>
Part3: Solutions in parametric form
Consider the system {x+2y+3z=6} of one equation in 3 variables. It is obvious that the solution is simply a plane. If we ask Maple to solve the system we get a solution that defines some of the variables in terms of themselves.
>
eq19 := x+2*y+3*z=6;
solve({eq19});
This indicates that we have a point in the solution for any pair of values assigned to y and z. We say that y and z are free variables, while x is a pivot variable. In terms of college algebra, we can only solve for one variable, in which case we might as well solve for x.
> solve(eq19,{x});
We would like to produce the translation vector, and spanning vectors for the solution in parametric form. The parametric form of the solution is a vector written in terms of the free variables. For this system it is:
[-2y-3z+6, y, z].
The translation vector is found by setting the free variables to constant values and simplifying. (Thus one can have many correct translation vectors.) Usually we use the simplest values: set the free variables to 0. This gives a translation vector of [6, 0, 0] for our system. The spanning vectors are obtained by taking the vectors corresponding to the coefficients of the free variables. For this system a set of spanning vectors is
{[-2, 1, 0], [-3, 0, 1]}.
In the next worksheet we will look at a way of automating the process of writing a solution to a system in parametric form.
Exercises:
5) Find the general solution to the system {eq10, eq11}. Express your answer in parametric form.
>
6) Find the general solution to the system {4x -2y -z -w =1, x +3y -2z -2w =2}. Express your answer in parametric form.
>
>