Skip to content
BIASED

Symmetric matrices and quadratic forms

Block 1 of 8~2 min

Why symmetric matrices are special

The topic Determinants and eigenvalues ended on a warning. A general matrix may have too few eigenvectors, or complex ones: a rotation by 90∘90^\circ has eigenvalues ±i\pm i, and the shear (1101)\begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix} has a single eigen-direction. Even when an eigenbasis exists, it is usually not orthogonal: the running example (4123)\begin{pmatrix} 4 & 1 \\ 2 & 3 \end{pmatrix} of that topic has eigenvectors (1,1)(1, 1) and (1,−2)(1, -2) at an angle of about 108∘108^\circ.

This topic is about matrices where none of that happens. A square matrix is symmetric if it equals its transpose:

A=A⊤,aij=aji.A = A^\top, \qquad a_{ij} = a_{ji}.

The entries mirror each other across the main diagonal. That sounds like a special case, but in ML symmetric matrices are the rule:

  • a covariance matrix, since Cov⁡(xi,xj)=Cov⁡(xj,xi)\operatorname{Cov}(x_i, x_j) = \operatorname{Cov}(x_j, x_i);
  • the Gram matrix X⊤XX^\top X of a data matrix XX, which already appeared in the normal equations (see the topic Inner products, norms and orthogonality);
  • a kernel matrix Kij=k(xi,xj)K_{ij} = k(x_i, x_j) built from a symmetric similarity kk;
  • the Hessian of a loss, its matrix of second derivatives (the topic Gradients, Jacobians and Hessians).

Why X⊤XX^\top X is symmetric takes one line with the rule (PQ)⊤=Q⊤P⊤(PQ)^\top = Q^\top P^\top:

(X⊤X)⊤=X⊤(X⊤)⊤=X⊤X.(X^\top X)^\top = X^\top (X^\top)^\top = X^\top X.

Nothing here needs XX to be square: the data matrix is N×dN \times d, with one example per row.

The running example of the topic is

A=(5222).A = \begin{pmatrix} 5 & 2 \\ 2 & 2 \end{pmatrix}.

Later it will turn out to be the covariance of a tiny dataset.

Answers are saved on the server and tied to this browser until you sign in.