This post is part of my Game Math Series.

### Definition of Matrix Multiplication

Let and be a -by- matrix and an -by- matrix, respectively. Let denote the element in the matrix on row and column (zero-based indexing), “element (, )” for short.

From the definition of matrix multiplication, we know that:

Essentially, element (, ) of the matrix product is the __dot product__ of -th row from and -th column from .

We can compute matrix multiplication by performing __one dot product per element__ in the resulting matrix product . However, there are two alternative ways to look at the matrix multiplication operation that can sometimes make your life easier. I learned these neat tips from the “Linear Algebra and Its Applications” course when I was studying at National Taiwan University back in Taiwan.

### Linear Combination of Columns

The -th column of the matrix product is a linear combination of columns from the __left matrix__ , where the coefficients of linear combination are from the -th column of the __right matrix__ .

Let’s look at a product of two 3-by-3 matrices as an example:

where denotes the -th column of matrix .

Then the -th column of the matrix product is:

Now let’s look at an example with real numbers:

The columns of are , , and . The first column of is , so the first column of the matrix product is:

Similarly, the second and third columns of the matrix product are:

So the matrix product is:

### Linear Combination of Rows

Alternatively, we can view matrix multiplication from a row perspective.

The -th row of the matrix product is a linear combination of rows from the __right matrix__ , where the coefficients of linear combination are from the -th row of the __left matrix__ .

Let denote the -th row of matrix .

I will skip the symbolic notations and jump right back into the previous example we used:

The rows of are , , and . The first rowof is , so the first column of the matrix product is:

Similarly, the second and third rows of the matrix product are:

So the matrix product is:

same as what we got before.

### End of Alternate Views on Matrix Multiplication

Now that you understand the two alternative views of matrix multiplication, you are well equipped to make your life easier when dealing with various matrix operations. For instance, I will show how to quickly eyeball the inverse of small matrices using this technique in another post.