Search code examples
pythonmatrixlinear-algebraeigenvalueeigenvector

The factorization of B could not be completed and no eigenvalues or eigenvectors were computed


I'm trying to solve the eigenvalue equation, A x = λ B x with A and B as 16×16 square Hermitian matrices. Using the linalg library on python (Spyder4) and I got an error saying:

LinAlgError: The leading minor of order 12 of B is not positive definite.  
             The factorization of B could not be completed and no eigenvalues or eigenvectors were computed.

here is the matrix and the command I used:

H = np.array([[a11,0,0,0,0,0,0,0,a19,a110,a111,a112,a113,a114,a115,a116] 
              [0,a22,0,0,0,0,0,0,a29,a210,a211,a212,a213,a214,a215,a216],
              [0,0,a33,0,0,0,0,0,a39,a310,a311,a312,a313,a314,a315,a316],
              [0,0,0,a44,0,0,0,0,a49,a410,a411,a412,a413,a414,a415,a416], 
              [0,0,0,0,a55,0,0,0,a59,a510,a511,a512,a513,a514,a515,a516],
              [0,0,0,0,0,a66,0,0,a69,a610,a611,a612,a613,a614,a615,a616], 
              [0,0,0,0,0,0,a77,0,a79,a710,a711,a712,a713,a714,a715,a716], 
              [0,0,0,0,0,0,0,a88,a89,a810,a811,a812,a813,a814,a815,a816], 
              [0,0,0,0,0,0,0,0,a99,0,0,0,0,0,0,0], 
              [0,0,0,0,0,0,0,0,0,a1010,0,0,0,0,0,0], 
              [0,0,0,0,0,0,0,0,0,0,a1111,0,0,0,0,0], 
              [0,0,0,0,0,0,0,0,0,0,0,a1212,0,0,0,0], 
              [0,0,0,0,0,0,0,0,0,0,0,0,a1313,0,0,0], 
              [0,0,0,0,0,0,0,0,0,0,0,0,0,a1414,0,0], 
              [0,0,0,0,0,0,0,0,0,0,0,0,0,0,a1515,0], 
              [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a1616]])  

S = np.array([[1,0,0,0,0,0,0,0,b19,b110,b111,b112,b113,b114,b115,b116], 
              [0,1,0,0,0,0,0,0,b29,b210,b211,b212,b213,b214,b215,b216],
              [0,0,1,0,0,0,0,0,b39,b310,b311,b312,b313,b314,b315,b316],
              [0,0,0,1,0,0,0,0,b49,b410,b411,b412,b413,b414,b415,b416], 
              [0,0,0,0,1,0,0,0,b59,b510,b511,b512,b513,b514,b515,b516],
              [0,0,0,0,0,1,0,0,b69,b610,b611,b612,b613,b614,b615,b616], 
              [0,0,0,0,0,0,1,0,b79,b710,b711,b712,b713,b714,b715,b716], 
              [0,0,0,0,0,0,0,1,b89,b810,b811,b812,b813,b814,b815,b816], 
              [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0], 
              [0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0], 
              [0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0], 
              [0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0], 
              [0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0], 
              [0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0], 
              [0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0], 
              [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]])

lamda, x = lg.eigh(H, S, lower=False, eigvals_only=False)
print("Eigenvalues")   
print(lamda)

The variables in the matrix are user inputs (Some -ve values, and complex numbers).

The eigenvalue is computed when I use "linalg.eig" command but since my actual matrix is symmetric, I'm trying to use eigh command.

Has anybody faced this problem and/or suggest what the error is about? Thanks


Solution

  • The documentation says that the second argument must be a complex Hermitian or a real symmetric definite positive matrix. If your b are complex, that it appears that this argument is neither.

    The documentation also says that this method throws a LinAlgError:

    If eigenvalue computation does not converge, an error occurred, or b matrix is not definite positive. Note that if input matrices are not symmetric or Hermitian, no error will be reported but results will be wrong.