Given a positive semi-definite matrix M, I would like to find its smallest nonzero eigenvalue. In python, this code looks enticing
import numpy as np
(w,v) = np.linalg.eigh(M)
minw = np.amin(w)
if (np.isclose(minw,0) and minw > 0):
print M, minw
Here is an example of a small input matrix.
[ 6 2 -4 -2]
[ 2 6 0 -6]
[-4 0 6 0]
[-2 -6 0 6]
Unfortunately, if you try this, you will receive 8.90238403828e-16. I don’t know how to determine if very small numbers should be zero or not.
How can you find the smallest nonzero eigenvalue of the matrix (and make sure it is really nonzero)?
source
share