Gauss Elimination (Unique Solutions)
We will now start to solve the systems of equation introduced in section 2
Consider two straight lines in two space.
2x + 3y = 5
3x + 2y = 6
You could solve the first equation for x and then plug the value into the second.
and then
which leads to
of y = 3/5
Now we go back to the first equation and have
and then solve for x
Another way is to go back to the equations and try to find two equation that go through the same point .
= 15/2 or (-1) (
The negative sign means to multiply the first equation (every term) and now we add replacing the second equation by the results of the addition.
or
y = 3/5
The equation on the right comes from the one on the left by multiplying both sides by -2/5. We can now use matrix notation to really get at what is going on.
| > |
Ab1:=addrow(Ab,1,2,-3/2); |
The addrow command comes from the with(linalg): package and is more descriptive of what is going on than the similar command in the with(LinearAlgebra) package.
The addrow is read as follows: multipliy row 1 by -3/2 and add to row 2. The row 1 is the first entry after the matrix Ab.
| > |
Ab2:=mulrow(Ab1,2,-2/5); |
 |
(2.1) |
We now see that y=3/5 since the entry in the 2,2 position is 1 and this is then the coefficient of y . Now to find the value of x
 |
(2.2) |
The value of x is obtained by taking 3* y=3*(3/5) and moving it to the right hand of the equation and then we have 2*x=(5-3*(3/5)). We want the value of x so the final calculation would be x=1/2*(5-3*(3/5));
The following is a short cut using Maple.
Notice that the way we are working is to make all entries under the 1,1 position zero. We will illustrate this with a 3x3. You need to read the next exmaple very carefully. Follow the pattern do not jump around. This is an algorithm and needs to be done in the correct order.
Exmaple 2
We will now look at a three by three to see what is going on.

and x + 3y +3z =3
or
Augmenting the coefficient matrix with the right hand side we obtain the matrix
We will now do row operations to get the coefficient matrix into upper triangular form. We will make the entries under the entry in the 1,1 position zero by using the addrow command then we will go to the entry in the 2,2 position and repeat the process.
| > |
E:=<<1|-2|1>,<-2|3|1>,<1|3|2>>; |
| > |
Ee2:=addrow(Ee1,1,3,-1); |
Now move to the entry in the 2,2 position and then zero out the entries below it. Here there is only the 5 in the 3,2 position.
| > |
Ee3:=addrow(Ee2,2,3,5); |
| > |
Ee4:=mulrow(Ee3,3,1/16); |
Let us do the back substitution one step at a time.
 |
(2.3) |
 |
(2.4) |
 |
(2.5) |
Unless the entry in the first row and first column is zero we will always work from the upper left hand corner to the lower right hand corner. This is an algorithm and you should never jump around in trying to obtain zeros when doing Gauss elimination. Sometimes we need to switch row when we encounter a zero as a pivot element. Using Maple with the addrow commands should help you with the process since you will not have to worry about using fractions. Students when doing problems by hand will try a lot of things to avoid using fractions. Again remember to always work from top to bottom and from left to right. You always want to zero out the elements under a pivot element.
We would like to consider the following system
Example 3.
| > |
C:=<<1|2|3|4>,<2|3|1|4>,<2|4|6|9>,<-1|3|2|1>>; |
| > |
Cc1:=addrow(Cc,1,2,-2); |
| > |
Cc2:=addrow(Cc1,1,3,-2); |
| > |
Cc3:=addrow(Cc2,1,4,1); |
| > |
Cc4:=addrow(Cc3,2,4,5); |
Notice that when we a zero as a pivot element in Cc4 i.e. (3.3) position above we used the swaprow command to get a non-zero element in the pivot position. The backsub command is a short cut for doing a step by step back substitution. Lets look at how we can carry out the process in a step by step method.
 |
(2.6) |
 |
(2.7) |
 |
(2.8) |
| > |
x:= -2*y - 3*z -4*w +1; |
 |
(2.9) |
As you can see we are assuming there is an equal sign before the last column and then moving the element to the left and changing sign and multiplying by the coefficient of the diagonal element to find the unknowns. Maple makes it easy to check that you have made no mistakes.
Gauss-Jordan
Another way to obtain the solutions to a system of equations is to continue past the row echelon form and convert the coefficient matrix to the identity. The solution will then be the last column of the augmented matrix. Let us return to Ee4
Example 2 Looked at again startin with Ee4
| > |
Ee5:=addrow(Ee4,3,2,-3); |
| > |
Ee6:=addrow(Ee5,3,1,-1); |
| > |
Ee8:=addrow(Ee7,2,1,2); |
As you can see we do not need to use the back substitution to find the solution.
We can also apply the Gauss-Jordan technique to the matrix Cc5; to finish the problem
Example 3 looked at again starting after Cc5.
| > |
Cc6:=addrow(addrow(addrow(Cc5,4,3,15),4,2,4),4,1,-4); |
| > |
Cc7:=mulrow(Cc6,3,-1/20); |
| > |
Cc8:=addrow(addrow(Cc7,3,2,5),3,1,-3); |
| > |
CC10:=addrow(Cc9,2,1,-2); |
Again look at each step. There is definite pattern to doing the operation. This is the shortest way to the answer. Just doing random row operations will cause you all kinds of problems. If you get this down correctly at this point you will have no problem when we get to the LU decomposition. If you jump around all over the place like at least one student does every term then you will have not hope when it comes to the LU decompostion.
If you computer can work in parallel the number of operation counts used for a Gauss-Jordan process will be the same or a little less than doing Gauss. If you computer does not use parallel processing then the number of operations counts for Gauss with backsub is considered better. (Time to each step)