Linear Algebra
9.510 min read

Gram and Covariance Matrices

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

If A=UΣV⊤A = U\Sigma V^\top, then K=AA⊤=U(ΣΣ⊤)U⊤K = AA^\top = U(\Sigma\Sigma^\top)U^\top — the spectral decomposition of KK, with eigenvalues σi2\sigma_i^2. Similarly, G=A⊤A=V(Σ⊤Σ)V⊤G = 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ΣV⊤A = U\Sigma V^\top. Then: - K=AA⊤=U(ΣΣ⊤)U⊤K = AA^\top = U(\Sigma\Sigma^\top)U^\top — spectral decomposition of KK - G=A⊤A=V(Σ⊤Σ)V⊤G = 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=1n−1XX⊤K = \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=B⊤EBK = B^\top E B is a Gram matrix.

Quiz

Question 1

The nonzero eigenvalues of AA⊤AA^\top and A⊤AA^\top A are always equal.

Question 2

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

Common Mistakes

  • Thinking AA⊤AA^\top and A⊤AA^\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).