Wednesday, March 25, 2009

A bit confused about how matrix multiplication?

If I want to multiple matrix A by matrix B ie. AB, the prerequisite is the number of rows in A needs to be the same as number of columns in B. For example if A is 2x2 and B is 2x3, it's good, because A has 2 rows and B as 2 columns. The other way around eg. BA would mean 2x3 against 2x2 and this cannot be performed.





I hope I am right with the concept above. What I don't understand now is, let's say P is a matrix of whatever size (for example 2 x 2). To calculate 3P I just multiple each element within the matrix P by 3. For example if P is a matrix of [1 2 on 3 4], then 3P gives me [3 6 on 9 12].





What I don't get is, the number 3 itself is like a matrix of 1 x 1 isn't it? So if look at 3P as a 1x1 matrix multiplying P which is a 2x2 matrix, I shouldn't be able to do it. The number of rows in the 1x1 matrix of "3" is not equal to the number of columns (2 columns) in P, how is the calculation do-able?





Hope my query is clear.... Thanks very much.



You don't have it quite right. If A is m x s and B is s x n then you can multiply A times B and the result is m x n. In words: You can multiply A times B if the number of COLUMNS of A equals the number of ROWS of B. One way to remember it is this: write down the dimensions of A next to the dimensions of B like this: m x s s x n. The two inner numbers must be the same for the multiplication to make sense. The two outer numbers are the dimension of the answer.





For your other question, multiplication by a scalar like 3 is NOT the same as multiplication by a matrix. Better to think of scalar multiplication (i.e. scalar times matrix) and matrix multiplication as two DIFFERENT operations.





However, if you interpret the scalar, like 3, as being 3 times the identity matrix, then it will work. For example, if the matrices are all 2 x 2, then multiplication by 3 gives the same answer as multiplying by:





3 0


0 3





I hope that clears it up.




The number 3 itself is not a matrix 1 x 1, it is a scalar.


The matrix theory defines a multiplication of a scalar and a matrix.




3 is a scalar not a vector!

No comments:

Post a Comment