Mathematics for AI and Machine Learning

Foundations for modern AI and machine learning

Gram Matrix

Chapter 4 Linear algebra

Chapter 4: QR Decomposition and Numerical Rank — Gram Matrices & Ortho Preservation (also appears in Ch. 7, Ch. 8)

High-resolution PNG
Gram Matrix — high-resolution mind-map icon

From the book

Chapter 4: QR Decomposition and Numerical Rank. In the chapter mind map this icon labels Gram Matrices & Ortho Preservation. The discussion below is excerpted and lightly edited from § Theorem: Rank Preservation with Orthonormal Matrices in Mathematics for AI and Machine Learning. Related material also appears in Chapter 7 (Gram Matrix(Column) $X^\top X$), Chapter 8 (Apps: Latent Embeddings, LSA & PCA).

Let $A \in \mathbb{R}^{M \times r}$ have orthonormal columns, so $\mathrm{rank}(A) = r$ and $A^\top A = I_{r \times r}$.

Upper bound: From equation the referenced section, $\mathrm{rank}(AB) \le \min\{\mathrm{rank}(A), \mathrm{rank}(B)\} = \min\{r, \mathrm{rank}(B)\} \le \mathrm{rank}(B)$.

Lower bound: Since $A^\top A = I_{r \times r}$, we have $B = A^\top (AB)$. Applying the rank inequality: From the upper bound, $\mathrm{rank}(AB) \le r$, so $\min\{r, \mathrm{rank}(AB)\} = \mathrm{rank}(AB)$. Therefore, $\mathrm{rank}(B) \le \mathrm{rank}(AB)$.

Combining both inequalities gives $\mathrm{rank}(AB) = \mathrm{rank}(B)$.

Since $\mathrm{Col}(AB) = A \cdot \mathrm{Col}(B)$ and $A$ has orthonormal columns, the linear transformation $A$ preserves dimension. Therefore, $\dim(\mathrm{Col}(AB)) = \dim(\mathrm{Col}(B))$, which implies $\mathrm{rank}(AB) = \mathrm{rank}(B)$.

What this drawing shows

What you see. Represents pairwise inner products between vectors, encoding lengths, angles, and similarity structure.

In the mind map. Chapter 4 — Gram Matrices & Ortho Preservation. See From the book above for definitions, figures, and worked examples.

Also appears in Ch. 7 (Gram Matrix(Column)); Ch. 8 (Apps: Latent Embeddings, LSA & PCA).

Where to read next

Open Chapter 4 companion →

Read the full definitions, figures, and worked examples in Chapter 4: QR Decomposition and Numerical Rank — see the mind-map node Gram Matrices & Ortho Preservation.

This concept is also referenced in Chapter 7 (Gram Matrix(Column)); Chapter 8 (Apps: Latent Embeddings, LSA & PCA).