# Why doesnt chol work for hermitian positive semi-definite matrix?

9 views (last 30 days)
Nikhil Challa on 25 Sep 2022
Answered: Pravarthana P on 28 Sep 2022
Hello,
I am trying to perform factorization of form A = R'*R using matlab function 'chol' but A is not positive definite, rather its hermitian positive semi-definite. As per theory from https://en.wikipedia.org/wiki/Hermitian_matrix , I should be able to perform factorization but matlab expects A to be positive definite matrix. Is there an alternative function in matlab?
Thanks,
##### 3 CommentsShow 1 older commentHide 1 older comment
Nikhil Challa on 25 Sep 2022
@Geoff Hayes , the https://en.wikipedia.org/wiki/Cholesky_decomposition link also talks about decomposition for hermitian positive semi-definite matrix except the solution may not be unique. Matlab has lot of functions that provide solution even for non-unique cases, so I would expect matlab to do the same for 'chol' function also.
Let me know if my understanding is incorrect.
Torsten on 25 Sep 2022

Pravarthana P on 28 Sep 2022
Hi Nikil Challa,
I understand that you are trying to perform factorization using “chol” function and are facing an issue with positive semi-definite matrix.
The “chol” function expects a symmetric positive definite matrix as input as mentioned in the documentation link.
The following can likely be a workaround to factorize positive semi-definite matrix:
1. Compute the LDL decomposition: A lower-triangular matrix L, a block-diagonal matrix D (1-by-1 and 2-by-2 blocks), and a permutation matrix P, such that A is P*L*D*L'*P' :
[L, D, P] = ldl(A);
2.Compute the eigenvalue decomposition, set its negative eigenvalues to zero, and use QR to get two triangular factors for this modified matrix:
[U, d] = eig(A, 'vector'); % A == U*diag(d)*U'
d(d < 0) = 0; % Set negative eigenvalues of A to zero
[~, R] = qr(diag(sqrt(d))*U');
% Q*R == sqrt(D)*U', so A == U*diag(d)*U'== R'*Q'*Q*R == R'*R
% In this case, check that d(d<0) are all nearly zero.
3.Add a small number to A’s diagonal before calling Cholesky:
R=chol(A+1e-13*eye(size(A)));
To know more information on why the “chol” function cannot be used to factorize positive semi-definite matrix, you can refer to the link.
I hope this information helps you.

### Categories

Find more on Linear Algebra in Help Center and File Exchange

R2021b

### Community Treasure Hunt

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

Start Hunting!