According to the MATLAB documentation for the function chol: "[R,p] = chol(A) for positive definite A, produces an upper triangular matrix R from the diagonal and upper triangle of matrix A, satisfying the equation R'*R=A and p is zero. If A is not positive definite, then p is a positive integer and MATLAB® does not generate an error"
I have found an example contradicting the behavior described so I do not understand if I can trust this function or whether there is an error in the documentation.
Let's have the following Matrix.
A = [[0.957166948 0.421761283 0.655740699 0.655740699];[0.485375649 0.915735525 0.035711679 0.035711679];[0.800280469 0.79220733 0.849129306 0.849129306];[0.141886339 0.959492426 0.933993248 0.933993248]];
Then the Cholesky factorization gives the following result:
[R,p] = chol(A)R = 0.9783 0.4311 0.6703 0.6703 0 0.8543 -0.2964 -0.2964 0 0 0.5586 0.5586 0 0 0 0.2913p = 0
So the p = 0 indicates according to the interpretation I have of the documentation that A is positive definite, which also indicates that the matrix A is nonsingular.
However this matrix is clearly singular given that the last two columns are identical. When computing the eigenvalues I get a zero eigenvalue which confirms this singularity. Also the determinant gives a numerical zero value.
> eig(A)ans = 2.5108 + 0.0000i -0.0000 + 0.0000i 0.5726 + 0.3574i 0.5726 - 0.3574i>> abs(det(A)) < epsans = logical 1
Conclusion: I can not conclude from P=0 in chol that the matrix is Positive definite.
Is there an error in this function, in the documentation or I am missing/misunderstanding something ?
I appreciate your help with this, dear MATLAB users.
Best Answer