To multiply two matrices, you don't just multiply the corresponding entries of the matrices – it's a bit more complicated than that.
The simplest matrices to multiply are a row matrix and a column matrix, provided they have the same number of entries.
To form the product of a 1 x n row matrix and a n x 1 column matrix, in that order, |
|
|
For example,
You can think of this product as either a scalar or a 1 x 1 matrix.
In general, you can't multiply matrices if their sizes don't "match": the "width" of the first has to be the same as the "height" of the second. Once that's true, you can multiply more general matrices just by multiplying all the rows of the first by all of the columns of the second.
To form the product of an m x n matrix A and an n x k matrix B: |
|
|
Here's an example.
Notice that the order of the matrices you're multiplying is important, since you always use rows from the first matrix and columns from the second. The two matrices above cannot be multiplied in the opposite order.
Unlike addition and scalar multiplication, matrix multiplication does not obey all the same rules that number multiplication does. Below are two lists. One gives the multiplication rules for number arithmetic that do work for matrix multiplication; the other lists the rules for number arithmetic that don't work for matrices.
Calculation rules for numbers that also work for matrices |
For any number a, 1a = a. |
|
For any number a, 0a = 0. |
|
For any numbers a, b and c, (ab)c = a(bc) (associative rule). |
|
For any numbers a, b and c, a(b + c) = ab + ac. |
|
Calculation rules for numbers that don't work for matrices. |
For any numbers a and b, ab = ba (commutative rule). |
|
For any numbers a, c and c, if ab = ac and a ≠ 0, then b = c (cancellation). |
|
For any numbers a and b, if ab = 0, then either a = 0 or b = 0. |
|
Square matrices can always be multiplied by themselves, so you can talk about their powers; for example A4 = AAAA. We define A0 = I for square matrices, so you can also talk about polynomials of square matrices – expressions such as 3A2 – 2A + 5I, for example.
However, many common algebraic identities don't work for square matrices. For
example, the "difference of squares" factoring doesn't work because,
for any same-sized square matrices A and B,
(A
+ B)(A –
B) = A(A
– B) + B(A
– B) = A2
– AB + BA
– B2,
which does not equal A2 – B2 unless AB = BA.