Error using chol Matrix must be positive definite.

24 visualizaciones (últimos 30 días)
Francois
Francois el 16 de Jun. de 2014
Comentada: Junho Kweon el 22 de Feb. de 2023
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 comentarios
John D'Errico
John D'Errico el 18 de Jun. de 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
Zhiyong Niu el 10 de Nov. de 2017
Editada: Zhiyong Niu el 10 de Nov. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

John D'Errico
John D'Errico el 17 de Jun. de 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.
  1 comentario
Junho Kweon
Junho Kweon el 22 de Feb. de 2023
I totally agree with this. Due to the limitation of the computation in MATLAB, sometimes minor computational error cause sight asymmetric or slightly-not-positive-definite matrix. I had same issue with @Francois, but the code as @John D'Errico showed solved this problem very well.

Iniciar sesión para comentar.

Más respuestas (1)

Youssef  Khmou
Youssef Khmou el 16 de Jun. de 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 comentario
Matt J
Matt J el 17 de Jun. de 2014
Editada: Matt J el 17 de Jun. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Linear Algebra en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by