The general algorithm for multiplying matrices is built on the row-times-column operation discussed above. Consider the following example:

1
2
3
4
5
6
7
8
9
10
11
12
1
2
3
4
5
6
7
8
9
10
11
12
size 12{ left [ matrix {
1 {} # 2 {} # 3 {} ##
4 {} # 5 {} # 6 {} ##
7 {} # 8 {} # 9 {} ##
"10" {} # "11" {} # "12"{}
} right ]} {}
10
40
20
50
30
60
10
40
20
50
30
60
size 12{ left [ matrix {
"10" {} # "40" {} ##
"20" {} # "50" {} ##
"30" {} # "60"{}
} right ]} {}

The key to such a problem is to think of the first matrix as a list of *rows* (in this case, 4 rows), and the second matrix as a list of *columns* (in this case, 2 columns). You are going to multiply each *row* in the first matrix, by each *column* in the second matrix. In each case, you will use the “dump truck” method illustrated above.

Start at the beginning: first row, times first column.

Now, move *down* to the next row. As you do so, move *down* in the answer matrix as well.

Now, move down the rows in the first matrix, multiplying each one by that same column on the right. List the numbers below each other.

The *first column* of the second matrix has become the *first column* of the answer. We now move on to the *second column* and repeat the entire process, starting with the first row.

And so on, working our way once again through all the rows in the first matrix.

We’re done. We can summarize the results of this entire operation as follows:

123456789101112123456789101112 size 12{ left [ matrix {
1 {} # 2 {} # 3 {} ##
4 {} # 5 {} # 6 {} ##
7 {} # 8 {} # 9 {} ##
"10" {} # "11" {} # "12"{}
} right ]} {}104020503060104020503060 size 12{ left [ matrix {
"10" {} # "40" {} ##
"20" {} # "50" {} ##
"30" {} # "60"{}
} right ]} {}==
1403203207705001220680167014032032077050012206801670 size 12{ left [ matrix {
"140" {} # "320" {} ##
"320" {} # "770" {} ##
"500" {} # "1220" {} ##
"680" {} # "1670"{}
} right ]} {}

It’s a strange and ugly process—but everything we’re going to do in the rest of this unit builds on this, so it’s vital to be comfortable with this process. *The only way to become comfortable with this process is to do it. A lot.* Multiply a lot of matrices until you are confident in the steps.

Note that we could add more rows to the first matrix, and that would add more rows to the answer. We could add more *columns *to the second matrix, and that would add more columns to the answer. However—if we added a column to the first matrix, or added a row to the second matrix, we would have an illegal multiplication. As an example, consider what happens if we try to do this multiplication in reverse:

10
40
20
50
30
60
10
40
20
50
30
60
size 12{ left [ matrix {
"10" {} # "40" {} ##
"20" {} # "50" {} ##
"30" {} # "60"{}
} right ]} {}
1
2
3
4
5
6
7
8
9
10
11
12
1
2
3
4
5
6
7
8
9
10
11
12
size 12{ left [ matrix {
1 {} # 2 {} # 3 {} ##
4 {} # 5 {} # 6 {} ##
7 {} # 8 {} # 9 {} ##
"10" {} # "11" {} # "12"{}
} right ]} {}
*Illegal multiplication*

If we attempt to multiply these two matrices, we start (as always) with the first row of the first matrix, times the first column of the second matrix:
[
10
40
]
[
10
40
]
1471014710 size 12{ left [ matrix {
1 {} ##
4 {} ##
7 {} ##
"10"
} right ]} {}. But this is an illegal multiplication; the items don’t line up, since there are two elements in the row and four in the column. So you cannot multiply these two matrices.

This example illustrates two vital properties of matrix multiplication.

- The number of columns in the first matrix, and the number of rows in the second matrix, must be equal. Otherwise, you cannot perform the multiplication.
- Matrix multiplication is not
*commutative*—which is a fancy way of saying, order matters. If you reverse the order of a matrix multiplication, you may get a different answer, or you may (as in this case) get no answer at all.

Comments:"DAISY and BRF versions of this collection are available."