Given a positive semi-definite matrix M I would like to find its smallest non-zero eigenvalue. In python this code looks tempting
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 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 get 8.90238403828e-16. I don't know in general how to tell if very small numbers are meant to be zero or not.
How can you find the smallest non-zero eigenvalue of a matrix (and be sure it really is non-zero)?