##### Gershgorin discs
 Gershgorin discs Pythia8 Unladen Swallow Posts: 2 Threads: 2 Joined: Jan 2021 Reputation: 1 Jan-11-2021, 11:13 AM Showing how the Gershgorin discs coincide with the spectrum for a diagonal matrix. In the first image is the original matrix as the scaling factor p=1 and, in the following images the off-diagonal elements are scaled away by decreasing p. Hence, the diagonal elements approaches the eigenvalues and the Gerschgorin discs decreases in radius and disappears. Bold circles represents eigenvalues and pluses are midpoints of the circles. ```from pylab import * import scipy.linalg as sl import matplotlib.pyplot as plt A = array([[5,0,0,-1] ,[1,0,-3,1] ,[-1.5,1,-2,1] ,[-1,5,3,-3]]) pval = np.arange(0, 1.1, 0.1) k = len(A) i = 0 def scaled(A,p): A = (p*(ones((4,4)) -eye(4)) +eye(4))*A return A def gerschgorin(B): B = scaledA - diag(scaledA)*eye(k) radvec = zeros(k) for i in range(k): radvec[i] = sum(abs(B[i,:])) return radvec for p in pval: scaledA = scaled(A,p) radius = gerschgorin(scaledA) fig,ax = plt.subplots() for i in range(k): circle = plt.Circle((A[i,i],0), radius[i], fill=False) ax.add_artist(circle) z = sl.eig(scaledA)[0] plt.scatter(z.real, z.imag, marker="o", c="black") plt.scatter(diag(A), zeros(k), marker="+", c="black") plt.axis('equal') plt.xlim(-7.5, 7.5) plt.title('Eigenvalues of scaled matrix p={0:.2f}'.format(round(p,2))) plt.xlabel('eigenvalue real part') plt.ylabel('eigenvalue imaginary part') plt.show() plt.close() i+=1``` Gribouillis likes this post Reply Posts: 2,813 Threads: 33 Joined: Jan 2018 Reputation: 256 Jan-11-2021, 12:12 PM Nice! You could add a slider widget in the plot to allow dynamic adjustment of p. There is a slider demo in the matplotlib documentation. Reply

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020