MATLAB: How to determine if a matrix is positive definite using MATLAB

choldefiniteeigeigenvalueMATLABpositivesemipositive

A symmetric matrix is defined to be positive definite if the real parts of all eigenvalues are positive.
A non-symmetric matrix (B) is positive definite if all eigenvalues of (B+B')/2 are positive.

Best Answer

This change has been incorporated into the documentation in Release 14 Service Pack 3 (R14SP3). For previous releases, read below for any additional information:
Rather than using the EIG function to obtain the eigenvalues in order to determine positive definiteness, it is more computationally efficient to use the CHOL function. The CHOL function provides an optional second output argument "p" which is zero if the matrix is found to be positive definite. If the input matrix is not positive definite, then "p" will be a positive integer:
>>[~,p] = chol(zeros(3))
p =
1
The CHOL function will return an error if it is only provided with a single output argument, and is also given a matrix that is not positive definite. NOTE: CHOL expects its input matrix to be symmetric and only looks at the upper triangular portion of the matrix.