Transpose and special matrices
Form the transpose, use (AB)ᵀ = BᵀAᵀ, recognise symmetric, diagonal, identity and triangular matrices, and read the Gram matrix XᵀX of a data matrix as the table of dot products of its columns.
It opens on
Flip a matrix across its diagonal and the picture it makes of the unit square changes: how, and which rules survive the flip when we multiply?
Why it matters
Data matrices have samples as rows and features as columns, so XᵀX, a symmetric table of feature-against-feature dot products, sits under covariance, least squares and PCA.
Good to know first
- Multiplication as composition: sizes of a product and that AB differs from BA
- Four views of the product: entries as dot products of rows and columns
- Norms and distance: the dot product as a measure of how two vectors point
Step by step
The transpose and (AB)ᵀ
Form Aᵀ by turning rows into columns and show that (AB)ᵀ = BᵀAᵀ on one example.
For A = [[2, 1], [0, 1]], the rows (2, 1) and (0, 1) become the columns of Aᵀ = [[2, 0], [1, 1]]; A sends e₁ to (2, 0) and e₂ to (1, 1), a parallelogram through (3, 1).
A common mix-up
(AB)ᵀ = AᵀBᵀ, since transposing just flips.
In fact: The order reverses: (AB)ᵀ = BᵀAᵀ.
Symmetric, diagonal, identity and triangular
Recognise the four special shapes, test symmetry with Sᵀ = S, and see that AᵀA is always symmetric.
S = [[2, 1], [1, 2]] is symmetric; it sends e₁ to (2, 1) and e₂ to (1, 2), swapped coordinates of each other, so the image is its own mirror image across y = x.
A common mix-up
Every square matrix with a nice picture is symmetric.
In fact: Symmetry means Sᵀ = S entry by entry; A = [[2, 1], [0, 1]] is not symmetric.
The Gram matrix XᵀX
Compute XᵀX for a data matrix and read each entry as a dot product of two columns, and the diagonal as squared lengths.
By the row-column rule, entry (i, j) of XᵀX is cᵢ · cⱼ, so XᵀX is the table of all dot products of columns, called the Gram matrix.
A common mix-up
XᵀX and XXᵀ are the same matrix.
In fact: They have different sizes (here 2 × 2 and 3 × 3) and compare features and samples respectively.
Try it
Transpose [[1, 0, 2], [3, −1, 4]] and give its size.Answer
[[1, 3], [0, −1], [2, 4]], 3 × 2
Hint: Row 1 becomes column 1
Compute AᵀA for A = [[1, 1], [0, 1]] and say whether it is symmetric.Answer
[[1, 1], [1, 2]]; yes
Hint: Aᵀ = [[1, 0], [1, 1]]
For X with columns (2, 1, 3) and (1, 1, 2), find XᵀX.Answer
[[14, 9], [9, 6]]
Hint: 2 · 1 + 1 · 1 + 3 · 2 = 9
A is 3 × 5. What size is Aᵀ, and where does the entry in row 2, column 4 of A sit in Aᵀ?Answer
5 × 3; row 4, column 2.
Is [[1, 2], [3, 1]] symmetric, and what single change makes it so?Answer
No, entries 2 and 3 differ; make them equal.
