These are examples done in class with MATLAB on Thursday, 9/9/04.

The example below is the augmented matrix for the system we did on
Tuesday, 9/7/04. The lines below enter the augmented matrix, which
MATLAB then echoes.

aug=[1 -2 1 -5; 2 -3 4 -12; 3 1 2 1]

aug =

     1    -2     1    -5
     2    -3     4   -12
     3     1     2     1


The next command runs MATLAB's rrefmovie (rref stands for reduced
echelon form). It is a package that helps illustrate row reducing a
matrix. 

rrefmovie(aug)
  Original matrix

A =

      1           -2            1           -5      
      2           -3            4          -12      
      3            1            2            1      

Press any key to continue. . .
  swap rows 1 and 3          

A =

      3            1            2            1      
      2           -3            4          -12      
      1           -2            1           -5      

Press any key to continue. . .
  pivot = A(1,1)          

A =

      1           1/3          2/3          1/3     
      2           -3            4          -12      
      1           -2            1           -5      

Press any key to continue. . .
  eliminate in column 1          

A =

      1           1/3          2/3          1/3     
      2           -3            4          -12      
      1           -2            1           -5      

Press any key to continue. . .
 

A =

      1           1/3          2/3          1/3     
      0         -11/3          8/3        -38/3     
      1           -2            1           -5      

 

A =

      1           1/3          2/3          1/3     
      0         -11/3          8/3        -38/3     
      0          -7/3          1/3        -16/3     

Press any key to continue. . .
  pivot = A(2,2)          

A =

      1           1/3          2/3          1/3     
      0            1          -8/11        38/11    
      0          -7/3          1/3        -16/3     

Press any key to continue. . .
  eliminate in column 2          

A =

      1           1/3          2/3          1/3     
      0            1          -8/11        38/11    
      0          -7/3          1/3        -16/3     

Press any key to continue. . .
 

A =

      1            0          10/11        -9/11    
      0            1          -8/11        38/11    
      0          -7/3          1/3        -16/3     

 

A =

      1            0          10/11        -9/11    
      0            1          -8/11        38/11    
      0            0         -15/11        30/11    

Press any key to continue. . .
  pivot = A(3,3)          

A =

      1            0          10/11        -9/11    
      0            1          -8/11        38/11    
      0            0            1           -2      

Press any key to continue. . .
  eliminate in column 3          

A =

      1            0          10/11        -9/11    
      0            1          -8/11        38/11    
      0            0            1           -2      

Press any key to continue. . .
 

A =

      1            0            0            1      
      0            1          -8/11        38/11    
      0            0            1           -2      

 

A =

      1            0            0            1      
      0            1            0            2      
      0            0            1           -2      

Press any key to continue. . .

The last "press any key ..." gives back the command promt. Of course,
the final matrix above, which is the row reduced form of the the
original augmented matrix, allows us to simply read off the solution
to the original problem. In this case, x1 = 1, x2 = 2, and x3 = -1. 

We now enter the augmented matrix for a new system, one with 2 equations
and 4 unknowns.

aug=[1 -2 1 2 -1; -1 2 0 -3 2]

aug =

     1    -2     1     2    -1
    -1     2     0    -3     2

rrefmovie(aug) 
  Original matrix

A =

      1           -2            1            2           -1      
     -1            2            0           -3            2      

Press any key to continue. . .
  pivot = A(1,1)          

A =

      1           -2            1            2           -1      
     -1            2            0           -3            2      

Press any key to continue. . .
  eliminate in column 1          

A =

      1           -2            1            2           -1      
     -1            2            0           -3            2      

Press any key to continue. . .
 

A =

      1           -2            1            2           -1      
      0            0            1           -1            1      

Press any key to continue. . .
  column 2 is negligible

A =

      1           -2            1            2           -1      
      0            0            1           -1            1      

Press any key to continue. . .
  pivot = A(2,3)          

A =

      1           -2            1            2           -1      
      0            0            1           -1            1      

Press any key to continue. . .
  eliminate in column 3          

A =

      1           -2            1            2           -1      
      0            0            1           -1            1      

Press any key to continue. . .
 

A =

      1           -2            0            3           -2      
      0            0            1           -1            1      

Press any key to continue. . . (This reutrns the prompt.)

Our final example is a system that is inconsistent - i.e., it has no
solution. As before, we enter its augmented matrix, and then row
reduce that martix.

aug=[1 1 1 2; 1 -1 2 0; 2 0 3 9]

aug =

     1     1     1     2
     1    -1     2     0
     2     0     3     9

rrefmovie(aug)
  Original matrix

A =

      1            1            1            2      
      1           -1            2            0      
      2            0            3            9      

Press any key to continue. . .
  swap rows 1 and 3          

A =

      2            0            3            9      
      1           -1            2            0      
      1            1            1            2      

Press any key to continue. . .
  pivot = A(1,1)          

A =

      1            0           3/2          9/2     
      1           -1            2            0      
      1            1            1            2      

Press any key to continue. . .
  eliminate in column 1          

A =

      1            0           3/2          9/2     
      1           -1            2            0      
      1            1            1            2      

Press any key to continue. . .
 

A =

      1            0           3/2          9/2     
      0           -1           1/2         -9/2     
      1            1            1            2      

 

A =

      1            0           3/2          9/2     
      0           -1           1/2         -9/2     
      0            1          -1/2         -5/2     

Press any key to continue. . .
  pivot = A(2,2)          

A =

      1            0           3/2          9/2     
      0            1          -1/2          9/2     
      0            1          -1/2         -5/2     

Press any key to continue. . .
  eliminate in column 2          

A =

      1            0           3/2          9/2     
      0            1          -1/2          9/2     
      0            1          -1/2         -5/2     

Press any key to continue. . .
 

A =

      1            0           3/2          9/2     
      0            1          -1/2          9/2     
      0            1          -1/2         -5/2     

 

A =

      1            0           3/2          9/2     
      0            1          -1/2          9/2     
      0            0            0           -7      

Press any key to continue. . .
  column 3 is negligible

A =

      1            0           3/2          9/2     
      0            1          -1/2          9/2     
      0            0            0           -7      

At this point in the process, we can see that the system has no
solution. The reason is the last row gives us the equation, 

0·x1 + 0·x2 + 0·x3 = -7, 

which implies 0 = -7. Since this is impossible, the system has no
solution. We will let MATLAB finish row reducing the matrix.


Press any key to continue. . .
  pivot = A(3,4)          

A =

      1            0           3/2          9/2     
      0            1          -1/2          9/2     
      0            0            0            1      

Press any key to continue. . .
  eliminate in column 4          

A =

      1            0           3/2          9/2     
      0            1          -1/2          9/2     
      0            0            0            1      

Press any key to continue. . .
 

A =

      1            0           3/2           0      
      0            1          -1/2          9/2     
      0            0            0            1      

 

A =

      1            0           3/2           0      
      0            1          -1/2           0      
      0            0            0            1      

Press any key to continue. . .
diary off