Matrix multiplication

How do you multiply matrices? I realized that the technique that I learned back in the days is not as common as I thought. I often see my students struggling to perform simple matrix multiplications, and I would argue that part of the reason is that they write them side-by-side. This is also what I see in the books I could get my hands on, and in some popular videos online.

To perform the multiplication AB of two matrices, I learned to write things in the way depicted in the picture below.

The advantages are multiple. First, to compute the element in position (i,j) of AB, the definition of matrix multiplication says that we need the i-th row of A and the j-th column of B, which we can neatly see at the left and the top of position (i,j).

Therefore, doing the operation A_{i,1}B_{1,j} + A_{i,2}B_{2,j} + \cdots requires only a minimum of mental gymnastics and eye movement.

Multiply the term connected by the dotted lines, then add all of them.

Added advantage:the matrix multiplication formula

\displaystyle (AB)_{i,j} = \sum_{k=1}^{n} A_{i,k} B_{k,j},

is right there under your eyes, no need to remember it. Provided of course that we remember that an element (i,j) is in the i-th row and j-th column, not vice versa, but this is convention and we cannot do anything about it.

A third selling point of this method is that it makes it easy to see the size of matrices.

  1. We can multiply A and B if we can “lay down” B on A after rotating it 90^{\circ}. In other words, the top part of A and left part of B can be glued together perfectly. In symbols, we can multiply a m \times n matrix by a n \times p matrix.
  1. The matrix multiplication AB fits snuggly in the space left on the right of A and the bottom of B. In other words, the product of a m \times n matrix by a n \times p matrix is a m \times p matrix.

As far as I am concerned, this is the only way I can recover all these formulas.

Consider matrices A_1, \dots, A_k of size respectively (m_1,n_1), \dots, (m_k,n_k). Under what conditions is the matrix product A_1 \cdots A_k well-defined? What is the size of the resulting matrix?

Consider a square n \times n matrix A, and the column vector \mathbf{1} of size n \times 1 that is filled with 1. Explain in words what A \mathbf{1}, \mathbf{1}^T A and \mathbf{1}^T A \mathbf{1} are. The exponent {}^T is the transpose.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s