Qm
Core

Quadratic Forms

A way of writing 'weighted sums of squares and cross-products', like portfolio variance, as a single matrix expression, whose sign and shape are governed entirely by the matrix's eigenvalues.

Prerequisites: Eigenvalues & Eigenvectors

Portfolio variance isn't just a sum of each asset's individual variance, it also depends on how every pair of assets moves together. Writing that out term by term for even a modest portfolio produces a sprawling expression full of covariance terms. A quadratic form is the compact way to package all of that: one matrix, one vector, one expression, and, crucially, a guarantee that the result behaves sensibly (never negative, for a real variance) that falls straight out of the matrix's eigenvalues.

An analogy: a bowl versus a saddle

Picture the graph of a function of two variables as a landscape. Some landscapes are bowls, every direction you walk from the bottom, you go up. Some are saddles, walk one way and you go up, walk another and you go down. A quadratic form is the algebraic recipe behind that landscape's shape, and whether it's a bowl (always positive), an upside-down bowl (always negative), or a saddle (mixed) is fixed entirely by the eigenvalues of the underlying matrix, no need to trace out the whole landscape to know which one you have.

The math, one symbol at a time

For a symmetric matrix AA and a vector xx, the quadratic form is the scalar

Q(x)=xAx=i,jAijxixj.Q(x) = x^\top A x = \sum_{i,j} A_{ij} x_i x_j.

In words: multiply every pair of entries xi,xjx_i, x_j by the matrix entry AijA_{ij} that links them, and add everything up. When AA is a covariance matrix and xx is a vector of portfolio weights, Q(x)Q(x) is exactly the portfolio's variance, diagonal terms Aiixi2A_{ii}x_i^2 are each asset's own variance contribution, off-diagonal terms AijxixjA_{ij}x_ix_j capture how pairs move together.

The matrix's eigenvalues classify the shape: if every eigenvalue is positive, AA is positive definite and Q(x)>0Q(x) > 0 for every nonzero xx (a bowl); if eigenvalues are mixed in sign, Q(x)Q(x) can go either way (a saddle); if some eigenvalue is exactly zero, Q(x)Q(x) can be zero for a nonzero xx (positive semidefinite, the flat direction of a valley floor).

Worked example 1: portfolio variance by hand

Two assets with variances σ12=0.04\sigma_1^2 = 0.04, σ22=0.09\sigma_2^2 = 0.09 and covariance 0.030.03 give covariance matrix A=(0.040.030.030.09)A = \begin{pmatrix}0.04 & 0.03\\0.03 & 0.09\end{pmatrix}. For weights x=(0.6,0.4)x = (0.6, 0.4):

Q(x)=0.04(0.6)2+0.09(0.4)2+2(0.03)(0.6)(0.4)=0.0144+0.0144+0.0144=0.0432.Q(x) = 0.04(0.6)^2 + 0.09(0.4)^2 + 2(0.03)(0.6)(0.4) = 0.0144 + 0.0144 + 0.0144 = 0.0432.

Portfolio variance is 0.0432, so volatility is 0.043220.8%\sqrt{0.0432} \approx 20.8\%. Every piece of that number came directly from the quadratic form, no separate variance-of-a-sum derivation needed.

Worked example 2: checking positive definiteness

Is B=(2332)B = \begin{pmatrix}2 & 3\\3 & 2\end{pmatrix} a valid covariance-style matrix? Its eigenvalues solve (2λ)29=0(2-\lambda)^2 - 9 = 0, giving λ=5\lambda = 5 and λ=1\lambda = -1. One eigenvalue is negative, so BB is not positive definite, indeed x=(1,1)x = (1,-1) gives Q(x)=2(1)+2(1)+2(3)(1)(1)=46=2Q(x) = 2(1) + 2(1) + 2(3)(1)(-1) = 4 - 6 = -2, a negative "variance." A matrix like this could never legitimately arise as a covariance matrix; if you ever compute one and it looks like BB, it signals a data or estimation error, not a real risk structure.

Function explorer
-2222.0
x = 1.00f(x) = 2.000

Adjust the coefficient and watch the parabola flip from a bowl to an upside-down bowl as the leading sign changes, the one-dimensional version of what eigenvalue sign does to a quadratic form in many dimensions.

positive definite (bowl) indefinite (saddle)
Nested closed ellipses mean every eigenvalue is positive, a true bowl with a unique minimum. Crossing hyperbolas mean mixed-sign eigenvalues, a saddle with no minimum or maximum.

What this means in practice

Portfolio variance, quadratic penalty terms in regularized regression, and the second-order (curvature) term in a Taylor expansion of any risk or loss function are all quadratic forms. Optimizers rely on positive definiteness to guarantee a unique minimum exists; risk systems rely on it to guarantee variance estimates are never nonsensically negative. When a covariance matrix is estimated from limited historical data, it can come out only positive semidefinite or even mildly indefinite due to estimation noise, a problem addressed by the The Nearest Correlation Matrix Problem repair technique.

A quadratic form xAxx^\top A x packages all pairwise interaction terms into one expression, and its sign behavior, always positive, always negative, or mixed, is decided entirely by the signs of AA's eigenvalues.

Don't assume a matrix built from real-world data is automatically positive semidefinite just because it "should" represent a variance. Sample covariance matrices estimated from too few observations relative to the number of assets routinely pick up small negative eigenvalues from noise, producing a mathematically invalid negative "variance" for some portfolio. This is a data-quality symptom, not a paradox, it means the matrix needs repair (shrinkage or projection to the nearest valid matrix) before being used in optimization.

Discussion

Sign in to join the discussion · reading is open to everyone

💡 Discussion rules

  1. Ask and answer about this concept. Off-topic gets removed.
  2. No homework dumps. Show what you tried first.
  3. Corrections are welcome. Cite a source when you claim an error.

Loading discussion…

Related concepts

Practice in interviews

Further reading

  • Strang, Introduction to Linear Algebra, ch. 6
ShareTwitterLinkedIn