Quadratic forms and definiteness

The surface xᵀAx — bowl, saddle or trough — and how the eigenvalues decide which.

What you'll learn
  • Turn a symmetric matrix into a surface and back
  • Classify a matrix as definite, semidefinite or indefinite from its eigenvalues
  • See why this is the shape every optimisation problem is judged by

Sandwich a symmetric matrix between a vector and its transpose and you get a single number:

\[f(\mathbf{x}) = \mathbf{x}^{\mathsf{T}} A\,\mathbf{x}\]

For a 2×2 matrix this is

\[\begin{bmatrix} x & y \end{bmatrix} \begin{bmatrix} a & b \\ b & c \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = a x^2 + 2b\,xy + c\,y^2\]

— a quadratic function of two variables, which you can draw as a surface over the plane. That surface is the quadratic form, and its shape says something fundamental about \(A\).

The surface z = xᵀAx with the camera orbiting. Green and orange curves run along the two eigenvector directions. Drag a and c through zero, or push the cross term b past √(ac), and watch the bowl turn into a saddle.

Definiteness

Along an eigenvector \(\mathbf{v}\) of unit length, \(f(t\mathbf{v}) = t^2\,\mathbf{v}^{\mathsf{T}}A\mathbf{v} = \lambda t^2\). So each eigenvalue is the curvature of the surface along its own eigenvector, and their signs decide the shape:

Eigenvalues Name Surface
all positive positive definite a bowl with one lowest point
all negative negative definite an upside-down bowl
mixed signs indefinite a saddle
some zero, rest one sign semidefinite a trough, flat along the zero direction

That is why the cross term matters so much. With \(a = c = 1\), the matrix is positive definite only while \(\vert b\vert < 1\); push \(b\) past 1 and one eigenvalue turns negative, and the bowl tips into a saddle.

Normalising: the geometry of eigenvectors

Divide by the squared length and you get the normalised quadratic form, or Rayleigh quotient:

\[R(\mathbf{x}) = \frac{\mathbf{x}^{\mathsf{T}}A\,\mathbf{x}}{\mathbf{x}^{\mathsf{T}}\mathbf{x}}\]

It depends only on direction, and its largest and smallest values are exactly the largest and smallest eigenvalues, reached along their eigenvectors. Your notebook visualises this, and it is the same quantity the power-iteration animation used to estimate \(\lambda\).

PCA is this result applied to a covariance matrix: the direction that maximises the variance of the data is the top eigenvector, because variance along a unit direction is a quadratic form.

Why optimisation cares

Near any minimum, a smooth function looks like a quadratic form built from its Hessian — the matrix of second derivatives. Positive definite Hessian: a true minimum. Indefinite: a saddle point, where gradient descent can stall. This is the bridge into the convex optimization course, where a problem whose quadratic form is positive definite everywhere is called convex — and has exactly one bottom to find.

Try it yourself. With \(a = 1\) and \(c = 2\), find the exact value of \(b\) where the surface stops being a bowl, and check that the determinant \(ac - b^2\) is zero there. Then compute the eigenvalues at that point in the notebook and confirm one of them is zero.

View source on GitHub →