Matrix Multiplication
Matrix multiplication is different from scalar multiplication. First, the product of two matrices \textbf{AB} is defined if the number of columns of \textbf{A} is equal to the number of rows of \textbf{B}. The equivilency that defines the shape of two matrices that are multiplied is:
(kxn)(nxp)=(kxp)
If matrix A is of order (kxn) and matrix B is of order (nxp), then the product AB is defined. For example, if A is of order (2 x 3) and B is of order (3 x 5), then the product is defined (and the above is equivilency is true). The resultant matrix is of order (2 x 5). If A is of order (2 x 3) and B is of order (2 x 3) the product is undefined.
Notation
Before, looking at the mechanics of matrix multiplication, a quick note on more generalized matrix notation. When notating a matrix of arbitrary size, it is common to use $n$ as a column counter and $k$ as a row counter. For example, if one would like to notate an arbitrarily sized matrix A it is possible to write:
⎣⎢⎢⎡a11a21⋮ak1……⋱…a1na2n⋮akn⎦⎥⎥⎤
What is going on with all of the dots? They are the 'filler' that is used to notate that the matrix is of arbitrary size.
Mechanics of Matrix Multiplication
Elements of the product of two matrices are calculated as:
⎣⎢⎢⎡a11a21⋮ak1……⋱…a1na2n⋮akn⎦⎥⎥⎤⎣⎢⎢⎡b11b21⋮bn1……⋱…b1pb2p⋮bnp⎦⎥⎥⎤=⎣⎢⎢⎡c11c21⋮ck1……⋱…c1pc2p⋮ckp⎦⎥⎥⎤
How though is each element calculated? By computing the dot product of each row in matrix A with each column in matrix B.
Let's assume that two matrices are given:
A=[a11a21a12a22a13a23]
and
B=⎣⎡b11b21b31b12b22b32⎦⎤
We already know that:
AB=C=[c11c21c12c22]
To compute C, we need to compute each element:
- First, multiple the first row of A with the first column of B:
c11=(a11)(b11)+(a12)(b21)+(a13)(b31)
- Next, multiple the first row of A by the second column of B:
c12=(a11)(b12)+(a12)(b22)+(a13)(b32)
- Third, multiple the second row of A by the first column of B.
c21=(a21)(b11)+(a22)(b21)+(a23)(b31)
- Finally, multiple the second row of A by the second column of B.
c22=(a21)(b12)+(a22)(b22)+(a23)(b32)
Example
A=[491625]
B=⎣⎡−53−1093⎦⎤
Product: AB
AB=[4(−5)+1(3)+2(−1)9(−5)+6(3)+5(−1)4(0)+1(9)+2(3)9(0)+6(9)+5(3)]
=[−20+3−2−45+18−50+9+60+54+15]
=[−19−321569]
Product: BA
BA=⎣⎡−4(4)+0(9)3(4)+9(9)−1(4)+3(9)(−5)(1)+0(6)3(1)+9(6)(−1)1+3(6)(−5)2+0(2)3(2)+9(5)(−1)23(5)⎦⎤
=⎣⎡−209333−55717−105113⎦⎤
Multiplication Communicative
In general:
- AB ≠ BA
- A(BC) = (AB)C
- A(B + C) = AB + AC
- (B + C)A = BA + CA
Supplemental Video

