In this post and in the accompanying YouTube tutorial, we explain the following topics:
- Quadratic forms. The connection between quadratic forms and definite and semi-definite matrices.
- Definite matrices. Tests for determining if a matrix is positive (semi) definite, negative (semi) definite, or indefinite.
- Plotting of quadratic forms in MATLAB.
- Leading principal minors of matrices.
Let us consider the following function
(1)
where
(2)
where
(3)
where
(4)
In order to better illustrate the structure of quadratic forms, let us consider a 2D case below
(5)
and consequently, our original function takes the following form
(6)
Let us visualize these functions, for several values of the matrix
(7)
The function
The MATLAB code used to generate these plots is given below.
clear,pack,clc
x1=-50:2:50;
x2=-50:2:50;
[X1,X2]=meshgrid(x1,x2);
syms x1s
syms x2s
% P1 - positive definite completely symmetric with respect to the zero axis
%P=[1 0; 0 1];
% P2 - positive definite not completely symmetric
% P=[1 -2;1 5];
% P3 - negative definite
%P=[-1 -2;1 -5];
%P4 - indefinite
%P=[-1 -2; 1 2];
%P5 - positive semi-definite
P=[1 1; 1 1];
expression= [x1s x2s]*P*[x1s; x2s];
% print this expression in the command window to see the expanded form of
% the Z function
% use the expanded expression to define a new function
expand(expression)
V= X1.^2+X2.^2+(X1.*X2).*2
figure(1)
surf(V)
xlabel('x1')
ylabel('x2')
zlabel('V(x1,x2)')
Here, we need to mention one important fact about quadratic forms. Notice that in the definition of the quadratic form, given by Eq. (1), it is assumed that the matrix
(8)
Consequently, any non-symmetric matrix defines a quadratic form with a symmetric matrix. That is, for any non-symmetric matrix, we can find a quadratic form with a symmetric matrix.
From (6), we can see that the function
(9)
Positive-definite quadratic forms corresponding to the positive definite matrices
(10)
Let us analyze the last expression. Let us assume that
(11)
Let us consider the second term
(12)
The second term is positive for all
(13)
The last equation is equivalent to
(14)
To summarize, the quadratic form (6) is positive definite if
(15)
On the other hand, consider again the original matrix
(16)
The number
By using this test, we can determine that the matrices
Condition for positive definiteness:
Generally speaking, the n-dimensional matrix
(17)
is positive definite if and only if
- the first-order leading principal minor is positive, that is, the determinant of the upper left 1-by-1 corner of P is positive:
(18)
- the second-order leading principal minor is positive, that is, the determinant of the upper left 2-by-2 corner of P is positive:
(19)
- the third-order leading principal minor is positive, that is, the determinant of the upper left 3-by-3 corner of P is positive:
(20)
- …
- the determinant of the matrix P is positive (this is the
-th order leading principal minor)(21)
This is the Sylvester condition for testing the positive definiteness of a matrix.
Let us apply this test on the following matrix
(22)
We have
(23)
Consequently, the matrix
Let us now state definitions of negative definite, negative semidefinite, positive semidefinite, and indefinite matrices.
Negative definite matrix: A matrix
(24)
Negative semi-definite matrix: A matrix
(25)
Positive semi-definite matrix: A matrix
(26)
Indefinite matrix: A matrix
The matrix
(27)
We see that this quadratic form is positive semi-definite since for
Condition for negative definiteness: A matrix
(28)
That is, the matrix
Condition for indefiniteness: A matrix
The conditions for positive and negative semidefiniteness are different from the conditions for strict positive and negative definiteness since they involve all principal minors, and not only leading principal minors. Principal minors are simply obtained by erasing certain columns and rows of a matrix and computing the determinant. Here, the process of erasing the columns and rows is not only restricted to the last rows and columns such as in the case of leading principal minors. The column and row numbers should be identical. That is, the indices of deleted rows must be equal to the indices of deleted columns. For example, consider the 3×3 matrix
(29)
Its second order principal minors are
(30)
Condition for positive semi-definiteness: A matrix
Condition for negative semi-definiteness: A matrix