Matrix Multiplication as the Sum of Outer Products
The transpose of a matrix times itself is equal to the sum of outer products created by the rows of the matrix. I prove this identity.
Published
17 July 2020
In a previous post, I used the following identity. Let
A be an N×K matrix, and let an denote a K-dimensional row vector in A. Then the following holds:
A⊤A=n=1∑Nan⊤an.(1)
Note since an is a row vector, the operation an⊤an is an outer product, not a dot product. Thus, the K×K matrix A⊤A is the sum of N outer products. Let’s prove this.
Let 0 denote a K-dimensional row vector of all zeros. We can write A as
This is nothing deep. We are writing A as the sum of N matrices, each of which has shape N×K and is all zeros except for the n-th row vector an. Therefore we can write A⊤A as
because matrix multiplication distributes with respect to addition. It may not be obvious why this representation is helpful. Let’s write it out explicitly:
In Eq. 4, each term inside the sum, labeled C(n) is a matrix multiplication between a K×N matrix A⊤ and an N×K matrix B(n). This results in a K×K matrix C(n). Using the definition of matrix multiplication, where Cij(n)=(Ai,:⊤)⊤B:,j(n), we see that each C(n) is