Linear Algebra
9.510 min read

Gram and Covariance Matrices

Two symmetric PSD matrices arise naturally from any matrix AA: the Gram matrix G=AAG = A^\top A (size n×nn \times n) and the covariance matrix K=AAK = AA^\top (size m×mm \times m). Both are symmetric and PSD.

If A=UΣVA = U\Sigma V^\top, then K=AA=U(ΣΣ)UK = AA^\top = U(\Sigma\Sigma^\top)U^\top — the spectral decomposition of KK, with eigenvalues σi2\sigma_i^2. Similarly, G=AA=V(ΣΣ)VG = A^\top A = V(\Sigma^\top\Sigma)V^\top, also with eigenvalues σi2\sigma_i^2. So KK and GG share the same nonzero eigenvalues (both equal σi2\sigma_i^2), but have different sizes and different eigenvectors.

Formal View

Theorem 9.2 — Gram and Covariance via SVD
Let A=UΣVA = U\Sigma V^\top. Then: - K=AA=U(ΣΣ)UK = AA^\top = U(\Sigma\Sigma^\top)U^\top — spectral decomposition of KK - G=AA=V(ΣΣ)VG = A^\top A = V(\Sigma^\top\Sigma)V^\top — spectral decomposition of GG - The nonzero eigenvalues of both KK and GG are σ12σr2>0\sigma_1^2 \geq \cdots \geq \sigma_r^2 > 0.

KK and GG always share the same nonzero eigenvalues (the squared singular values of AA), even though they may have different sizes.

Interactive Visualization

Transpose Visualizer

Why This Matters

Gram and covariance matrices bridge SVD to the spectral theorem — they let you compute SVD using eigendecomposition.

  • In statistics, the covariance matrix K=1n1XXK = \frac{1}{n-1}XX^\top is the foundation of PCA.
  • Kernel methods: the Gram matrix encodes pairwise similarities.
  • Structural mechanics: the stiffness matrix K=BEBK = B^\top E B is a Gram matrix.

Quiz

Question 1

The nonzero eigenvalues of AAAA^\top and AAA^\top A are always equal.

Question 2

If AA has singular values 3,1,03, 1, 0, what are the eigenvalues of AAA^\top A?

Common Mistakes

  • Thinking AAAA^\top and AAA^\top A have the same eigenvalues — they share the NONZERO eigenvalues, but the sizes differ.
  • Confusing eigenvectors of KK (columns of UU) with those of GG (columns of VV).