Skip to content

Positive definite matrices

Draw xᵀAx as a surface and tell a bowl from a valley or a saddle, with four tests that ask the same question, and factor a bowl by Cholesky.

Helps to know firstSymmetric matrices

Helps to know first
This topic

First, the picture

A symmetric matrix draws a surface over the plane. Watch it change from a round bowl to a valley, then to a saddle.

Bowl, valley, saddle

The surface z = 2x^2 + 2sxy + 2y^2 of the matrix A = [2 s; s 2].

s = 0: z = 2x^2 + 2y^2, a round bowl. Both eigenvalues of A = [2 0; 0 2] are 2.

s
0
eigenvalues
2, 2
shape
round bowl
0.00 / 12.60 s
Describe this picture

A slowly turning 3-D view of the surface z=2x2+2sxy+2y2z=2x^2+2sxy+2y^2 over a round patch of the plane, for the matrix A(s)=[2ss2]\mathbf{A}(s)=\begin{bmatrix}2&s\\s&2\end{bmatrix}. Two curves run across the surface: along the line x=yx=y (labelled with the eigenvalue 2+s2+s) and along x=−yx=-y (labelled 2−s2-s). Two points on the rim are marked with their heights, z(1,1)z(1,1) and z(1,−1)z(1,-1). Parts of the surface below the floor are shaded in a second colour. Over about 12 s, ss moves from 0 to 1, to 2, to 3, resting at each. At s=0s=0 the surface is a round bowl. At s=1s=1 the bowl is stretched. At s=2s=2 it is a valley, flat along the line x=−yx=-y. At s=3s=3 it is a saddle: it rises along x=yx=y and falls along x=−yx=-y, where z(1,−1)=−2z(1,-1)=-2, while z(1,1)=10z(1,1)=10. Readouts give ss, the two eigenvalues and the shape. One control after the clip: a slider for ss from −3-3 to 3 in steps of 0.5.

Energy

A symmetric matrix A\mathbf{A} turns every point x\mathbf{x} into one number:

q(x)=x⊤Ax.q(\mathbf{x})=\mathbf{x}^\top\mathbf{A}\mathbf{x}.

For A(s)\mathbf{A}(s) in the picture, q(x,y)=2x2+2sxy+2y2q(x,y)=2x^2+2sxy+2y^2. Draw that number as a height above each point, and you get the surface. In mechanics and circuits qq is often an energy, which is why it matters whether it can go negative.

The matrix is positive definite when the surface is a bowl that touches zero only at the origin:

x⊤Ax>0for every x≠0.\mathbf{x}^\top\mathbf{A}\mathbf{x}>0\quad\text{for every}\ \mathbf{x}\neq\mathbf{0}.

When qq is never negative but can be 0 away from the origin, the matrix is positive semi-definite: a valley.

Which is it? Turn to the matrix’s axes. By Symmetric matrices, A=QΛQ⊤\mathbf{A}=\mathbf{Q}\boldsymbol{\Lambda}\mathbf{Q}^\top. Write (u,w)=Q⊤x(u,w)=\mathbf{Q}^\top\mathbf{x} for the coordinates of x\mathbf{x} along the two eigenvectors. Then

x⊤Ax=(Q⊤x)⊤Λ (Q⊤x)=λ1u2+λ2w2.\begin{aligned} \mathbf{x}^\top\mathbf{A}\mathbf{x}&=(\mathbf{Q}^\top\mathbf{x})^\top\boldsymbol{\Lambda}\,(\mathbf{Q}^\top\mathbf{x})\\ &=\lambda_1u^2+\lambda_2w^2. \end{aligned}

For A(s)\mathbf{A}(s) the eigenvectors are (1,1)/2(1,1)/\sqrt2 and (1,−1)/2(1,-1)/\sqrt2, with eigenvalues 2+s2+s and 2−s2-s. So q=(2+s) u2+(2−s) w2q=(2+s)\,u^2+(2-s)\,w^2. Both eigenvalues positive: a bowl. One of them 0: a valley along that eigenvector. One negative: a saddle. Drag ss past 2 and watch the surface bend down exactly when 2−s2-s goes below zero.

Four tests, one question

For a symmetric matrix, these four tests always agree. Each is a different way to ask “is the surface a bowl?”

  1. Eigenvalues. Every eigenvalue is positive. That is the formula λ1u2+λ2w2\lambda_1u^2+\lambda_2w^2 above.
  2. Pivots. Every pivot of elimination, from Elimination, is positive. Elimination writes qq as a sum of squares with the pivots as weights: 2x2+2xy+2y2=2(x+12y)2+1.5 y22x^2+2xy+2y^2=2\big(x+\tfrac12y\big)^2+1.5\,y^2, with pivots 2 and 1.5.
  3. Leading determinants. The determinants of the top-left 1×11\times1, 2×22\times2, … corners are all positive. Each one is a product of pivots: 2, then 2⋅1.5=32\cdot1.5=3.
  4. A product. A=B⊤B\mathbf{A}=\mathbf{B}^\top\mathbf{B} for some matrix B\mathbf{B} with independent columns. Then x⊤Ax=(Bx)⊤(Bx)=∥Bx∥2\mathbf{x}^\top\mathbf{A}\mathbf{x}=(\mathbf{B}\mathbf{x})^\top(\mathbf{B}\mathbf{x})=\lVert\mathbf{B}\mathbf{x}\rVert^2, a length squared, and it is 0 only when Bx=0\mathbf{B}\mathbf{x}=\mathbf{0}, which independence allows only for x=0\mathbf{x}=\mathbf{0}.

Four tests

Four ways to ask one question: is x^T A x > 0 for every nonzero x?

A = [2 1; 1 2], symmetric. Four tests ask one question: is x^T A x > 0 for every nonzero x?

0.00 / 9.80 s
Describe this picture

The matrix [2112]\begin{bmatrix}2&1\\1&2\end{bmatrix} as a grid of cells, and beside it (below it on a phone) its four tests appear one after another, each as a small grid with its name: its eigenvalues 3 and 1; its pivots 2 and 1.5; its leading determinants 2 and 3; and its lower triangular factor L\mathbf{L}, with 1.4141.414, 0.7070.707 and 1.2251.225, under the name “L, with LL⊤=A\mathbf{L}\mathbf{L}^\top=\mathbf{A}”. Under each, a check mark says “all > 0”: every test is passed. There is no control.

Watch out

Positive entries are not enough. [1221]\begin{bmatrix}1&2\\2&1\end{bmatrix} has every entry positive, but its pivots are 1 and 1−4=−31-4=-3, its eigenvalues 3 and −1-1, and q(1,−1)=1−4+1=−2q(1,-1)=1-4+1=-2: a saddle. And the eigenvalue test needs symmetry. [1301]\begin{bmatrix}1&3\\0&1\end{bmatrix} has eigenvalues 1 and 1, yet q(1,−1)=1−3+1=−1q(1,-1)=1-3+1=-1.

Cholesky: the square root of a bowl

Test 4 has a standard choice of B\mathbf{B}. Every positive definite matrix factors as

A=LL⊤,\mathbf{A}=\mathbf{L}\mathbf{L}^\top,

with L\mathbf{L} lower triangular and a positive diagonal. This is the Cholesky factorisation, and B=L⊤\mathbf{B}=\mathbf{L}^\top. It is the LU\mathbf{L}\mathbf{U} factorisation of LU factorisation with the pivots shared out evenly between the two factors. For [2112]\begin{bmatrix}2&1\\1&2\end{bmatrix}:

L=[201/21.5]≈[1.41400.7071.225].\begin{aligned} \mathbf{L}&=\begin{bmatrix}\sqrt2&0\\1/\sqrt2&\sqrt{1.5}\end{bmatrix}\\ &\approx\begin{bmatrix}1.414&0\\0.707&1.225\end{bmatrix}. \end{aligned}

Check: the top-left entry of LL⊤\mathbf{L}\mathbf{L}^\top is 2 2=2\sqrt2^{\,2}=2, the off-diagonal one 2⋅(1/2)=1\sqrt2\cdot(1/\sqrt2)=1, and the bottom-right 0.5+1.5=20.5+1.5=2. The diagonal of L\mathbf{L} holds the square roots of the pivots.

To solve Ax=b\mathbf{A}\mathbf{x}=\mathbf{b}, solve two triangular systems: first Lc=b\mathbf{L}\mathbf{c}=\mathbf{b} from the top down, then L⊤x=c\mathbf{L}^\top\mathbf{x}=\mathbf{c} from the bottom up. With b=(3,3)\mathbf{b}=(3,3), the first gives c=(2.121,  1.225)\mathbf{c}=(2.121,\;1.225) and the second x=(1,1)\mathbf{x}=(1,1). Check: A(1,1)=(3,3)\mathbf{A}(1,1)=(3,3).

Bowls, valleys and saddles in calculus

Near a point where a smooth function of two variables is flat, it looks like a surface 12 x⊤Hx\tfrac12\,\mathbf{x}^\top\mathbf{H}\mathbf{x}, where H\mathbf{H} is the symmetric matrix of its second derivatives, the Hessian. So the four tests decide what kind of point it is: positive definite means a minimum, and a negative eigenvalue means a saddle.

  • f=x2+xy+y2f=x^2+xy+y^2 has Hessian [2112]\begin{bmatrix}2&1\\1&2\end{bmatrix}, positive definite: the origin is a minimum.
  • f=x2+4xy+y2f=x^2+4xy+y^2 has f(1,−1)=1−4+1=−2f(1,-1)=1-4+1=-2: the origin is a saddle.
  • [4221]\begin{bmatrix}4&2\\2&1\end{bmatrix} has determinant 0: it is only semi-definite, a valley.

Here H\mathbf{H} is the Hessian, not the system matrix of signal processing.

Worked example

1. Four tests on one matrix. [2112]\begin{bmatrix}2&1\\1&2\end{bmatrix}: eigenvalues 3 and 1; pivots 2 and 1.5; leading determinants 2 and 3; Cholesky factor as above. At x=(1,−1)\mathbf{x}=(1,-1): q=2−2+2=2>0q=2-2+2=2>0.

2. A saddle. [1221]\begin{bmatrix}1&2\\2&1\end{bmatrix}: pivots 1 and −3-3, eigenvalues 3 and −1-1, q(1,−1)=−2q(1,-1)=-2.

3. A 3×33\times3 product. Take B=[110101011]\mathbf{B}=\begin{bmatrix}1&1&0\\1&0&1\\0&1&1\end{bmatrix}, whose columns are independent. Then

B⊤B=[211121112]\mathbf{B}^\top\mathbf{B}=\begin{bmatrix}2&1&1\\1&2&1\\1&1&2\end{bmatrix}

must be positive definite, and every test agrees: pivots 2, 1.5 and 4/34/3; leading determinants 2, 3 and 4; eigenvalues 4, 1 and 1. Its Cholesky factor is

L≈[1.414000.7071.22500.7070.4081.155],\mathbf{L}\approx\begin{bmatrix}1.414&0&0\\0.707&1.225&0\\0.707&0.408&1.155\end{bmatrix},

and the last row checks as 0.5+0.1667+1.3333=20.5+0.1667+1.3333=2. At x=(1,−1,0)\mathbf{x}=(1,-1,0), Bx=(0,1,−1)\mathbf{B}\mathbf{x}=(0,1,-1), so q=∥Bx∥2=2q=\lVert\mathbf{B}\mathbf{x}\rVert^2=2.

4. Correlated noise. The covariance matrix [1ρρ1]\begin{bmatrix}1&\rho\\\rho&1\end{bmatrix} has leading determinants 1 and 1−ρ21-\rho^2, so it is positive definite exactly when ∣ρ∣<1\lvert\rho\rvert<1. For ρ=0.8\rho=0.8, L=[100.80.6]\mathbf{L}=\begin{bmatrix}1&0\\0.8&0.6\end{bmatrix}.

Try these before you read the answers.

  • Is [200−1]\begin{bmatrix}2&0\\0&-1\end{bmatrix} positive definite? No: one eigenvalue is −1-1.
  • Is [4221]\begin{bmatrix}4&2\\2&1\end{bmatrix}? No, only semi-definite: its determinant is 0, a valley.
  • Can x⊤B⊤Bx\mathbf{x}^\top\mathbf{B}^\top\mathbf{B}\mathbf{x} be negative? No: it is ∥Bx∥2\lVert\mathbf{B}\mathbf{x}\rVert^2.
  • At which ss does A(s)\mathbf{A}(s) stop being a bowl? At s=2s=2, where 2−s2-s reaches 0.

In signal processing · prediction equations

Parametric models and linear prediction, in the signal processing course, solves a symmetric system built from a signal’s autocorrelations. That matrix is positive semi-definite, since c⊤Rc\mathbf{c}^\top\mathbf{R}\mathbf{c} is an average of squares, so the four tests of this page apply. There, bold R\mathbf{R} is the correlation matrix. Matrix entries count from 1, while lags count from 0.

Where you’ll meet this

Optimisation. A minimum of a smooth function has a positive definite Hessian. Newton’s method, the fast way to find a minimum, solves a linear system with that Hessian at each step, usually by Cholesky.

Covariance. A covariance matrix is B⊤B\mathbf{B}^\top\mathbf{B} for the centred data, divided by a count, so it is positive semi-definite, and positive definite unless one measurement is a fixed mix of the others.

Making correlated noise. To draw two Gaussian values with correlation 0.8, draw two independent ones z\mathbf{z} and form x=Lz\mathbf{x}=\mathbf{L}\mathbf{z} with the L\mathbf{L} of example 4: x2=0.8 z1+0.6 z2x_2=0.8\,z_1+0.6\,z_2. The covariance of x\mathbf{x} is LL⊤\mathbf{L}\mathbf{L}^\top.

Where this leads · covariance matrices

Covariance and correlation, in the probability and statistics course, measures how two quantities vary together. The matrix of those covariances is always positive semi-definite, by the argument of test 4 of this page.

Reference card

QuantityFormulaNotes
Energyq(x)=x⊤Axq(\mathbf{x})=\mathbf{x}^\top\mathbf{A}\mathbf{x}A\mathbf{A} symmetric
Positive definiteq(x)>0q(\mathbf{x})>0 for x≠0\mathbf{x}\neq\mathbf{0}a bowl
Semi-definiteq(x)≥0q(\mathbf{x})\ge0a valley allowed
Eigenvalue formq=∑kλk uk2q=\sum_k\lambda_k\,u_k^2uku_k: the coordinate along eigenvector kk
Four testsall λ>0\lambda>0; all pivots >0>0; all leading determinants >0>0; A=B⊤B\mathbf{A}=\mathbf{B}^\top\mathbf{B}B\mathbf{B} with independent columns
CholeskyA=LL⊤\mathbf{A}=\mathbf{L}\mathbf{L}^\topL\mathbf{L} lower triangular, diagonal =pivots=\sqrt{\text{pivots}}
SolveLc=b\mathbf{L}\mathbf{c}=\mathbf{b}, then L⊤x=c\mathbf{L}^\top\mathbf{x}=\mathbf{c}two triangular solves
Second-derivative testHessian positive definitea minimum

Keep reading with a free account.

By creating an account you accept the terms of use.

Sign in

Already have an account? Use the service you signed up with.

Or keep reading: get new lessons by email

Are you 13 or over?

Accounts and email updates are for people aged 13 or over. We keep only your answer, never your date of birth.

End of the lesson

Where to go next.

Phasorium

Account

Sign inKeep your place on any device

Subjects

Site

Look