Find the global bounds on the eigenvalues of a tridiagomal matrix in Python
''' lamMin,lamMax = gerschgorin(d,c). Applies Gerschgorin's theorem to find the global bounds on the eigenvalues of a tridiagomal matrix [A] = [c\d\c]. ''' def gerschgorin(d,c): n = len(d) lamMin = d[0] - abs(c[0]) lamMax = d[0] + abs(c[0]) for i in range(1,n-1): lam = d[i] - abs(c[i]) - abs(c[i-1]) if lam < lamMin: lamMin = lam lam = d[i] + abs(c[i]) + abs(c[i-1]) if lam > lamMax: lamMax = lam lam = d[n-1] - abs(c[n-2]) if lam < lamMin: lamMin = lam lam = d[n-1] + abs(c[n-2]) if lam > lamMax: lamMax = lam return lamMin,lamMax