Row Operations and Elementary Matrices

Author :  Thomas Shores
University of Nebraska
Send comments to :  tshores@math . unl . edu

Row Operations and Elementary Matrices

Suppose we are given a matrix A, such as:

a = {{1,2,7},{-1,0,3},{2,1,1}}

We would like to know if A possesses certain properties, one immediate example being whether we can solve A . x = b for any vector b. If we let the vector b = (1,0,0), then
the requirement  A . x = b breaks down into three (linear) equations:
 
             x1 + 2 x2 + 7 x3 = 1
           - x1 +            3 x3 = 0
           2 x1 +   x2  +   x3 = 0
      From algebra class we know we can manipulate these equations in certain ways and still
 keep the same set of solutions.  For example, we can add the first equation to the second and subtract twice the first equation from the third.  Then we get :
              x1 + 2 x2  +   7 x3 =   1
                      2 x2  + 10 x3 =   1
                     -3 x2  -  13 x3 = -2
     And now we could convert this system back into matrix form.  But dealing with variables and equations seems unnecessarily messy.  What we need are methods of manipulating the matrix itself while keeping its properties intact.  To do this, we need to think of the rows of the matrix as individual entities, which we can add (component by component), for example.  Now, in the case of linear systems, the following “equation operations” do not affect the solution set :
     (1)  Adding a multiple of one equation to another
     (2)  Exchanging two equations
     (3)  Multiplying an equation on both sides by a nonzero constant

    We can certainly do more, but it turns out that this set of operations is quite useful and sufficient for our purposes.   To show how these operations apply to matrices, it turns out that the following is  true:
    
FACT: (1)  Let Ei,j (α) (with i ≠ j) be the matrix defined by 
                                        1,   if k = l
               (Ei,j(α)) k,l  =  α,  if  k = i  and l = j
                                        0,  otherwise.
                   Then for any compatible matrix A, B = Ei,j(α) . A is a matrix the same as A
                           except  the  ith row of B is the ith row of A plus α times the jth row of A.
(2)  Let  Ei,j  (i ≠ j) be the matrix defined by     
                                     1,  if k = l and k ∉ {i,j}
                (Ei,j)k,l  =    1,  if {k,l} = {i,j}  (set-wise equality)    
                                     0,  otherwise.
                   Then the matrix Ei,j . A is equal to A, except the ith and jth rows of A have been
                         exchanged.   
(3)  Let Ei(α)  (α ≠ 0) be defined by
                                       1, if k = l and k ≠ i
                (Ei(α))k,l =    α, if k = l = i
                                       0, if k ≠ l.          
                     Then the matrix Ei(α) . A is the same as A, except the ith row has been
                         multiplied by α.                 
   The matrices  E* defined in the above fact are called elementary matrices and their role in Matrix Theory is important.  If the matrix Aaug = [A  b]  represents the equation A . x = b,
then multiplying  Aaug on the left by elementary matrices does not affect the solution of this system, but at the same time it can make the form of Aaug simpler.

Elementary Matrices in Mathematica

When performing row operations, often the matrices involved can be complicated and computational error unavoidable.  To this end, a program has been written in Mathematica to simulate these matrices.  Click in the next cell and press the key marked Enter to load in this program.

<< ElementaryMatrices.ma

Because Mathematica does not have subscripts, certain notational liberties have been made:
                               Ei,j(α) . A  ≡  EM [i,j,α, A]
                                     Ei,j . A ≡  EM [{i,j},A]
                                  Ei(α) . A ≡  EM [i,α,A]
Note particularly the braces ({}) in Ei,j to distinguish it from Ei(α), purely for the  machine's sake. Now let's do some row operations on the following matrix. ( Click in the cells and press enter to activate them.)

a = {{1,1,1},{1,0,1},{1,0,0}}

MatrixForm[a]

EM [1,3,5,a];

Note two things at this point : first, the semicolon at the end of the command, which keeps the result from being printed in “machine form” -- the program prints the result of the operation if it is legal -- and second, that EM [1,3,5,A] really means E1,3(5) . A.  A simple computation shows this is what was expected.  Now let's do some more row operations from this matrix;  the symbol % means to use the last output as input, even though we could have saved the previous result as another matrixwith a command like b = EM [1,3,5,a].

EM [{1,3},%];

We see we have swapped the first and third rows of our new matrix.  What happens if we try to swap a row, such as the fifth, which isn't there?  Let's try it ...

EM [{1,5},%];

Aha!  The programmer saw ahead to people possibly mis-using this routine (this phenomenon is called -- perhaps inappropriately -- the “ idiot test”) and lets us know that something is wrong.  The routine saw that our matrix has  three rows and so we couldn't possibly have a fifth row.  So we don't  need to tell how big our matrix is; Mathematica takes care of it for us.  Another feature of the program is that if we do get a message like this, we can still use the % to mean “ the last matrix printed”, so that we don't have to re-work everything if we just happen to make a typo. Now let's multiply the first row by 5:

EM [1,5,%];

This brings up an important point : the last two commands were almost alike, so we must be careful at times like this.  And if we try to multiply a row by zero, we get :

EM [2,0,%];

... and the program tells us simply that we're trying to do something wrong.