MATLAB Answers

Error using chol Matrix must be positive definite.

112 views (last 30 days)
Francois
Francois on 16 Jun 2014
Edited: Zhiyong Niu on 10 Nov 2017
I have a positive definite matrix C for which R=chol(C) works well. I want to apply the chol function to a new matrix A = U*C*U' where U is a unitary matrix obtained as output from SVD, i.e. from [V,S,U] = dvd(T); but I get an error telling me that A is not positive definite. I checked that det(U) = 1.0 so I don't understand why the symmetric matrix A is not positive definite.
Given that C is positive definite then y'*C*y>0 and if I let y = U'*x then x'*U*C*U'*x>0 which implies that U*C*U'is also positive definite.
Is this problem due to round off or am I missing some important linear algebra concept. If not is there a way around this problem?
  8 Comments
Zhiyong Niu
Zhiyong Niu on 10 Nov 2017
The diagnal of a positive definite matrix is real. However, if you obtain A by A = U*C*U' ,the diagnal of A may have imagenary parts, even though they are extremely tiny, on the order of 1e-17i. if so, the chol() may give you an error when the elements of diagnal was checked.

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 17 Jun 2014
One solution is to use my nearestSPD code as found on the file exchange. It handles the semi-definite matrix, finding the smallest perturbation into a positive definite matrix, one that will be ASSUREDLY factorizable using chol.

More Answers (1)

Youssef  Khmou
Youssef Khmou on 16 Jun 2014
this an interesting problem,
Generally, the matrix C must contain some negative and positive eigenvalues ( eig(C)) according the description, in the other hand, the matrix A is positive semi definite only if C is diagonal matrix with the diagonal elements being the eigenvalues corresponding the eigenvectors U(:,1),....U(:,N).
In this case you multiply C whether diagonal or not with non corresponding eigenvectors, so A can not be positive semi definite .
  1 Comment
Matt J
Matt J on 17 Jun 2014
A is positive semi definite only if C is diagonal matrix with the diagonal elements being the eigenvalues corresponding the eigenvectors U(:,1),....U(:,N).
Not true. Suppose U=eye(N). Then A=C and both are positive (semi) definite simultaneously, regardless of whether C is diagonal.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!