The matrix product and its uses
The matrix product: row by column
A rule different from addition
Unlike addition, the product of two matrices is not done cell by cell. To multiply A (of size n x k) by B (of size k x p), the number of columns of A must equal the number of rows of B. The result A x B is then a matrix of size n x p.
The row x column rule
Each coefficient of the result is obtained by taking a whole row of A and a whole column of B, multiplying the terms one by one in order, then adding everything up.
Product A x B, with A = [[1,2],[3,4]] and B = [[5,6],[7,8]]:
column1 column2
[ 5 ] [ 6 ]
[ 7 ] [ 8 ]
row1 [1 2] -> 1*5 + 2*7 = 5+14 = 19 | 1*6 + 2*8 = 6+16 = 22
row2 [3 4] -> 3*5 + 4*7 = 15+28 = 43 | 3*6 + 4*8 = 18+32 = 50
Result:
[ 19 22 ]
A x B = [ 43 50 ]
(coefficient at row 1 column 1 = term-by-term product of row 1 of A and column 1 of B, then sum)
General method
To find the coefficient at position (i, j) of the product: take the whole row i of A, the whole column j of B, multiply each pair of aligned terms, then add all these products. Each coefficient of the result therefore requires a sum of products, not a simple multiplication.
Common pitfall
The matrix product is in general NOT commutative: A x B is almost always different from B x A (and B x A may not even exist if the sizes do not match in that order). You must also check that the sizes are compatible (columns of A = rows of B) before even starting the calculation, otherwise the product does not exist.

