Why does the identity matrix times another matrix yield a third matrix?

111 Views Asked by At

From what I learned, multiplying any matrix with the Identity Matrix of Multiplication results in the same matrix again. Here's also an example of this. I've tried the following in NumPy:

>>> m = np.array([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]], float)
>>> m
array([[ 1.,  0.,  0.,  0.],
      [ 0., -1.,  0.,  0.],
      [ 0.,  0.,  0.,  1.],
      [ 0.,  0.,  1.,  0.]])
>>> np.identity(4)
array([[ 1.,  0.,  0.,  0.],
      [ 0.,  1.,  0.,  0.],
      [ 0.,  0.,  1.,  0.],
      [ 0.,  0.,  0.,  1.]])
>>> np.identity(4) * m

I would expect the result of the last line to be the same as m, but it's not.

array([[ 1.,  0.,  0.,  0.],
      [ 0., -1.,  0.,  0.],
      [ 0.,  0.,  0.,  0.],
      [ 0.,  0.,  0.,  0.]])

What about the "Identity Matrix" statement, that any matrix multiplied with a compatible identity matrix (or the other way round) results in the same matrix?