Error using chol Matrix must be positive definite.
Afficher commentaires plus anciens
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 commentaires
John D'Errico
le 17 Juin 2014
Modifié(e) : John D'Errico
le 17 Juin 2014
That det(A)==1 is NOT any assurance that the matrix is not numerically singular. In fact, it is trivial to create a matrix that has a determinant equal to ANY value, yet it still be singular in double precision.
A = diag([1e10,1e-10]);
Clearly, the determinant is 1. As clearly, it is also effectively a numerically singular matrix in double precision.
A = diag([1e10,1e-10]);
det(A)
ans =
1
rank(A)
ans =
1
cond(A)
ans =
1e+20
NEVER use the determinant as a measure of singularity. NEVER. NEVER. NEVER. That you may have read it in a book is irrelevant. That you may have seen it in some text that is 40 years old is irrelevant. Sadly, the authors of books today are still referring back to those texts they learned from 40+ years ago, still teaching their own students the wrong things about numerical methods.
Youssef Khmou
le 17 Juin 2014
that is correct, what about the condition number : lambda_max/lambda_min ?
John D'Errico
le 17 Juin 2014
cond returns that value. see my example. It is a good predictor of numerical singularity, certainly far better than det. Of course, a random number generator can be as good as det in that respect.
Francois
le 17 Juin 2014
Ricardo Almeida
le 18 Juin 2016
I´m having the same problem. Without going into peculiarities of decomposition methods, I think it might be some technical issue. I'm running chol function in two different computers, both Windows 7 64bits and matlab 2015a. One flags a positive definite matrix and other don't (Maybe it's a coincidence but always return the number of columns).
John D'Errico
le 18 Juin 2016
The most common reason for this is NOT the difference in code, which should not be, but how you pass the array between. Too often people think they can pass an ascii file between the two machines, that this is sufficient.
Unless the array is passed EXACTLY between machines as a .mat file, you are NOT making a proper comparison. Without use of a .mat file, there will be tiny errors in the least significant bits.
Zhiyong Niu
le 10 Nov 2017
Modifié(e) : Zhiyong Niu
le 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.
Réponse acceptée
Plus de réponses (1)
Youssef Khmou
le 16 Juin 2014
0 votes
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 commentaire
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.
Catégories
En savoir plus sur Linear Algebra dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!