Matrix Multiplication

You can only multiply two matrices if their dimensions are compatible, which means the number of columns in the first matrix is the same as the number of rows in the second matrix. If A is an a × b matrix and B is a b × c matrix, the product AB is an a × c matrix.

The definition of matrix multiplication indicates a row-by-column multiplication, where the entries in the ith row of A are multiplied by the corresponding entries in the jth row of B and then adding the results.

Matrix multiplication is NOT commutative.   If neither A nor B is an identity matrix, AB ≠ BA.

Multiplying a Row by a Column

We'll start by showing you how to multiply a 1 × n matrix by an n × 1 matrix. The first is just a single row, and the second is a single column. By the rule above, the product is a 1 × 1 matrix; in other words, a single number.

First, let's name the entries in the row r1, r2, ..., rn, and the entries in the column c1, c2, ..., cn. Then the product of the row and the column is the 1 × 1 matrix

[r1c1 + r2c2 + ... + rncn].

Example:

Find the product.

We have to multiply a 1 × 3 matrix by a 3 × 1 matrix. The number of columns in the first is the same as the number of rows in the second, so they are compatible.

The product is:

[(1)(2) + (4)(–1) + (0)(5)]

= [2 + (–4) + 0]

= [–2]

Multiplying Larger Matrices

Now that you know how to multiply a row by a column, multiplying larger matrices is easy. For the entry in the ith row and the jth column of the product matrix, multiply each entry in the ith row of the first matrix by the corresponding entry in the jth row of the second matrix and adding the results.

Let's take the following problem, multiplying a 2 × 3 matrix with a 3 × 2 matrix, to get a 2 × 2 matrix as the product. The entries of the product matrix are called eij when they're in the ith row and jth column.

To get e11, multiply Row 1 of the first matrix by Column 1 of the second.

To get e12, multiply Row 1 of the first matrix by Column 2 of the second.

To get e21, multiply Row 2 of the first matrix by Column 1 of the second.

To get e22, multiply Row 2 of the first matrix by Column 2 of the second.

Writing the product matrix, we get:

Therefore, we have shown: