Elementary Row Operations

Elementary Row Operations

Elementary row operations:
    Replace: replace one row by the sum of that row and a constant multiple of another row.
    Swap: interchange two rows
    Scale: multiply a row by a non-zero constant
Let's use the elementary row operations to reduce a matrix to row echelon form.

In[1]:=

a = ({{1, -2, 1, 0}, {2, 0, -8, 8}, {-4, 5, 9, -9}}) ;

In[2]:=

a[[2]] = a[[2]] - 2a[[1]] ;

a//MatrixForm

Out[3]//MatrixForm=

( {{1, -2, 1, 0}, {0, 4, -10, 8}, {-4, 5, 9, -9}} )

In[4]:=

a[[3]] = a[[3]] + 4a[[1]] ;

a//MatrixForm

Out[5]//MatrixForm=

( {{1, -2, 1, 0}, {0, 4, -10, 8}, {0, -3, 13, -9}} )

In[6]:=

a[[3]] = a[[3]] + 3/4a[[2]] ;

a//MatrixForm

Out[7]//MatrixForm=

( {{1, -2, 1, 0}, {0, 4, -10, 8}, {0, 0, 11/2, -3}} )

Elementary Matrices

Define procedures which create elementary matrices.
Premultiplication of a given matrix by an elementary matrix effects an elementary row operation.

In[8]:=

eReplace[n_, i_, a_, j_] := Module[{e = IdentityMatrix[n]}, e[[i]] = e[[i]] + a e[[j]] ; e] 

eSwap[n_, i_, j_] := Module[{e = IdentityMatrix[n], temp},  temp = e[[i]] ; e[[i]] = e[[j]] ; e[[j]] = temp ; e] 

eScale[n_, i_, a_] := Module[{e = IdentityMatrix[n]}, e[[i]] = a e[[i]] ; e]

Testing. Create some elementary matrices.

In[11]:=

a = ({{1, -2, 1, 0}, {2, 0, -8, 8}, {-4, 5, 9, -9}}) ; 

eReplace[3, 2, -2, 1]//MatrixForm

eSwap[3, 1, 2]//MatrixForm

eScale[3, 1, -1]//MatrixForm

Out[12]//MatrixForm=

( {{1, 0, 0}, {-2, 1, 0}, {0, 0, 1}} )

Out[13]//MatrixForm=

( {{0, 1, 0}, {1, 0, 0}, {0, 0, 1}} )

Out[14]//MatrixForm=

( {{-1, 0, 0}, {0, 1, 0}, {0, 0, 1}} )

Echelon Form

Use elementary row operations to reduce a matrix  to row echelon form.
Premultiplication by elementary matrices accomplishes the transformation.

In[15]:=

a = ({{1, -2, 1, 0}, {2, 0, -8, 8}, {-4, 5, 9, -9}}) ; 

e1 = eReplace[3, 2, -2, 1] ;

e2 = eReplace[3, 3, 4, 1] ; 

e2 . e1 . a ;

%//MatrixForm

Out[19]//MatrixForm=

( {{1, -2, 1, 0}, {0, 4, -10, 8}, {0, -3, 13, -9}} )

In[20]:=

e3 = eReplace[3, 3, 3/4, 2] ; 

e3 . e2 . e1 . a ;

%//MatrixForm

Out[22]//MatrixForm=

( {{1, -2, 1, 0}, {0, 4, -10, 8}, {0, 0, 11/2, -3}} )

Reduced Echelon Form

Use row reduction to solve a system of linear equations.

In[23]:=

a = ({{1, -2, 1, 0}, {0, 2, -8, 8}, {-4, 5, 9, -9}}) ; 

r = RowReduce[a] ;

%//MatrixForm

Out[25]//MatrixForm=

( {{1, 0, 0, 29}, {0, 1, 0, 16}, {0, 0, 1, 3}} )

Let's check that.

In[26]:=

<<LinearAlgebra`MatrixManipulation`

In[27]:=

m = TakeColumns[a, 3] ;

%//MatrixForm

s = TakeColumns[r, -1] ;

%//MatrixForm

b = TakeColumns[a, -1] ;

%//MatrixForm

m . sb

Out[28]//MatrixForm=

( {{1, -2, 1}, {0, 2, -8}, {-4, 5, 9}} )

Out[30]//MatrixForm=

( {{29}, {16}, {3}} )

Out[32]//MatrixForm=

( {{0}, {8}, {-9}} )

Out[33]=

True


Created by Mathematica  (December 15, 2004) Valid XHTML 1.1!