Behavior of Elimination Matrices

In [3]:
#keep
import numpy as np
In [30]:
#keep
n = 4

Let's create some elimination matrices:

In [40]:
#keep
M1 = np.eye(n)
M1[1,0] = 0.5
M1
Out[40]:
array([[ 1. ,  0. ,  0. ,  0. ],
       [ 0.5,  1. ,  0. ,  0. ],
       [ 0. ,  0. ,  1. ,  0. ],
       [ 0. ,  0. ,  0. ,  1. ]])
In [41]:
#keep
M2 = np.eye(n)
M2[3,0] = 4
M2
Out[41]:
array([[ 1.,  0.,  0.,  0.],
       [ 0.,  1.,  0.,  0.],
       [ 0.,  0.,  1.,  0.],
       [ 4.,  0.,  0.,  1.]])
In [42]:
#keep
M3 = np.eye(n)
M3[2,1] = 1.3
M3
Out[42]:
array([[ 1. ,  0. ,  0. ,  0. ],
       [ 0. ,  1. ,  0. ,  0. ],
       [ 0. ,  1.3,  1. ,  0. ],
       [ 0. ,  0. ,  0. ,  1. ]])

Now play around with them:

In [43]:
#keep
M1.dot(M2)
Out[43]:
array([[ 1. ,  0. ,  0. ,  0. ],
       [ 0.5,  1. ,  0. ,  0. ],
       [ 0. ,  0. ,  1. ,  0. ],
       [ 4. ,  0. ,  0. ,  1. ]])
In [44]:
#keep
M2.dot(M1)
Out[44]:
array([[ 1. ,  0. ,  0. ,  0. ],
       [ 0.5,  1. ,  0. ,  0. ],
       [ 0. ,  0. ,  1. ,  0. ],
       [ 4. ,  0. ,  0. ,  1. ]])
In [45]:
#keep
M1.dot(M2).dot(M3)
Out[45]:
array([[ 1. ,  0. ,  0. ,  0. ],
       [ 0.5,  1. ,  0. ,  0. ],
       [ 0. ,  1.3,  1. ,  0. ],
       [ 4. ,  0. ,  0. ,  1. ]])

BUT:

In [47]:
#keep
M3.dot(M1).dot(M2)
Out[47]:
array([[ 1.  ,  0.  ,  0.  ,  0.  ],
       [ 0.5 ,  1.  ,  0.  ,  0.  ],
       [ 0.65,  1.3 ,  1.  ,  0.  ],
       [ 4.  ,  0.  ,  0.  ,  1.  ]])