How do I determine if a matrix is positive definite using MATLAB?
216 views (last 30 days)
Show older comments
MathWorks Support Team
on 9 Sep 2013
Commented: guygyuggfff
on 17 Jun 2021
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.
Accepted Answer
MathWorks Support Team
on 9 Sep 2013
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.
3 Comments
Walter Roberson
on 24 Dec 2013
I think Sepehr is implying that the "p" output of chol() is returning 0, implying that chol thinks it is positive definite. (I have not tried it myself.)
Mohammad Haghighat
on 14 Mar 2014
Edited: Mohammad Haghighat
on 14 Mar 2014
Unfortunately, I couldn't see the code since the open-source code for chol.m was not available for me.
However, they might have considered " greater than or equal" as in the definition of " positive semi-definite ". That might be the reason why it gives a 0 to p.
More Answers (0)
See Also
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!