Positive definite matrices#
A square matrix \(\boldsymbol A \in \mathbb R^n\) is called
positive definite if \(\boldsymbol x^\mathsf{T}\boldsymbol{Ax} > 0\) for all \(\boldsymbol x \in \mathbb R^n\), \(\boldsymbol x \ne \boldsymbol 0\);
positive semidefinite if \(\boldsymbol x^\mathsf{T}\boldsymbol{Ax} \geqslant 0\) for all \(\boldsymbol x \in \mathbb R^n\);
negative definite if \(\boldsymbol x^\mathsf{T}\boldsymbol{Ax} < 0\) for all \(\boldsymbol x \in \mathbb R^n\), \(\boldsymbol x \ne \boldsymbol 0\);
negative semidefinite if \(\boldsymbol x^\mathsf{T}\boldsymbol{Ax} \leqslant 0\) for all \(\boldsymbol x \in \mathbb R^n\).
For example, matrix \(\boldsymbol A = \begin{pmatrix} 1 & 0 \\ -1 & 2 \end{pmatrix}\) is positive definite since for any nonzero vector \(\begin{pmatrix} x \\ y \end{pmatrix}\) we have
Symmetric matrices#
The positive definiteness of a symmetric matrix \(\boldsymbol A = \boldsymbol A^\mathsf{T}\) of shape \(n\times n\) is equivalent to any of the following statements:
all \(n\) eigenvalues of \(\boldsymbol A\) are positive
all \(n\) pivots of \(\boldsymbol A\) are positive
all \(n\) upper left determinants are positive
\(\boldsymbol A = \boldsymbol B^\mathsf{T} \boldsymbol B\) for some full column rank matrix \(\boldsymbol B\)
Proof of statement 1
According to spectral theorem
where \(\boldsymbol Q\) is orthogonal, and diagonal matrix \(\boldsymbol \Lambda\) consists of eigenvalues of \(\boldsymbol A\). Hence,
Note that \(\boldsymbol x \ne \boldsymbol 0\) iff \(\boldsymbol y \ne \boldsymbol 0\) (why?). Finally observe that expression
is positive for any \(\boldsymbol y \ne \boldsymbol 0\) iff \(\lambda_i>0\) for all \(i\).
Numeric example#
Create some random positive definite matrix using statement 4, and check theat all other statements are fulfilled:
import numpy as np
A = np.random.normal(size=(5, 4))
B = A.T @ A
eigvals, _ = np.linalg.eig(B)
print("eigenvalues:", eigvals)
print("left upper determinants:", [float(np.linalg.det(B[:i, :i])) for i in range(4)])
eigenvalues: [8.3450636 2.98702351 0.76122108 0.48962739]
left upper determinants: [1.0, 2.195774261287806, 13.876758598100098, 8.106837599831954]
To find pivots use LU-decomposition from scipy:
from scipy.linalg import lu
_, _, U = lu(B)
print("Echelon form:")
print(U)
Echelon form:
[[ 2.19577426 -0.30395801 0.36388171 1.38597395]
[ 0. 6.31975647 0.6802934 -2.76674215]
[ 0. 0. 0.58420254 0.20999453]
[ 0. 0. 0. 1.14602299]]
Ellipses and ellipsoids#
The canonical ellipse equation is
It is specified by a diagonal matrix \(\mathrm{diag}\{\frac 1{a^2}, \frac 1{b^2}\}\) with positive diagonal elements. \(a\) and \(b\) are the axis lengths of the ellipse.
A tilted ellipse is defined by equations
where \(\boldsymbol x = (x, y)^\mathsf T\), and matrix
is positive definite. The axis of such ellipse come from the spectral theorem:
The lined-up ellipse \(\boldsymbol y^{\mathsf T}\boldsymbol{\Lambda}\boldsymbol y = 1\) has axes of \(\frac 1{\sqrt \lambda_i}\), and then it is rotated by (orthogonal) rotation matrix \(\boldsymbol Q\). This also works for \(n\)-dimensional ellipsoids.
Exercises#
Show that diagonal matrix \(\mathrm{diag}\{\lambda_1, \ldots, \lambda_n\}\) is positive definite iff all \(\lambda_i >0\).
Prove that matrix \(\boldsymbol A^\mathsf{T} \boldsymbol A\) is always semipositive definite, and it is positive definit iff \(\boldsymbol A\) has full column rank.
Prove that matrix \(\boldsymbol A\) is positive definite if
Prove that inverse to a positive definite symmetric matrix is also symmetric and positive definite.
Find the axes of this tilted ellipse \(5x^2 + 8xy + 5y^2 = 1\).
Show that \(\boldsymbol A^\mathsf{T} \boldsymbol A\) and \(\boldsymbol{AA}^\mathsf{T}\) have same positive eigenvalues \(\sigma_1, \ldots, \sigma_r\) for any \(\boldsymbol A \in \mathbb R^{m\times n}\) of rank \(r\).