Is the matrix for Cholesky decomposition semidefinite or definite?

93 Views Asked by At

So we have a matrix $A$. We need to check if it is positive definite (numerically). At lectures we have done that with brute-force Cholesky decomposition, and if any of the square roots is not defined, then that would imply that it is not positive definite.

However on Wikipedia I read that Cholesky decomposition works for semi-definite matrices.

So if I am not wrong, we made a mistake, because (by the method mentioned above) we solved the equation $z^TAz\geq0$ which implies semi-positive definite and not equation $z^TAz >0$.

My question is: Is it still possible to see if a matrix is positive-definite with using Cholesky decomposition?

1

There are 1 best solutions below

0
On BEST ANSWER

The semi-definite matrix $$ A=\begin{pmatrix}1&1\\1&1\end{pmatrix} $$ has obviously the Cholesky decomposition $A=LL^\top$ where $$ L=\begin{pmatrix}1&0\\1&0\end{pmatrix}\,. $$ To the celebrated Cholesky-Banachiewicz algorithm you have to make only a minimal modification to make it work for any semi-definite matrix $A$:

def my_cholesky( A ):
    L = array([[0.0,0.0],[0.0,0.0]]) # I apologize for 2x2
    for i in range(len(A)):
        for j in range(len(A[i])):
            L[i][j] = 0.0
    for i in range(len(A)):
        for j in range(i+1):
            sum = 0
            for k in range(j):
                sum += L[i][k]*L[j][k]
            if i == j:
               L[i][j] = sqrt(A[i][i]-sum)
            else: # with small modifications to make it work
                  # for semi defininte A
               if L[j][j] > 1e-15:
                  L[i][j] = (A[i][j]-sum)/L[j][j]
               else:
                  L[i][j] = 0 
    return L