Linear algebra: Gershgorin Circle Theorem

1 minute read

Published:

Gershgorin Circle Theorem

The Gershgorin Circle Theorem provides an insightful perspective on the location of eigenvalues in the complex plane. Every eigenvalue of a matrix lies within at least one of the Gershgorin discs.

Given an (N \times N) matrix (A), each Gershgorin disk is centered at (a_{kk}) and has a radius given by:

[ r_k = \sum_{j \neq k}a_{kj}]

This means that the eigenvalues of (A) are guaranteed to be located within these discs.

Python Visualization of Gershgorin Circles

Here’s a Python code snippet that employs numpy and matplotlib to visualize the Gershgorin circles and the actual eigenvalues for a provided matrix:

```python import numpy as np import matplotlib.pyplot as plt

def gershgorin(A): N = A.shape[0] circles = [] for k in range(N): center = A[k, k] radius = np.sum(np.abs(A[k, :])) - np.abs(center) circles.append((center, radius)) return circles

def plot_gershgorin(A): circles = gershgorin(A) eigenvalues = np.linalg.eigvals(A)

fig, ax = plt.subplots(figsize=(10, 10))
colors = plt.cm.viridis(np.linspace(0, 1, len(circles)))

for idx, (center, radius) in enumerate(circles):
    circle = plt.Circle((center.real, center.imag), radius, color=colors[idx], fill=False, label=f'Circle {idx+1}')
    ax.add_artist(circle)
    ax.text(center.real, center.imag, f"{idx+1}", fontsize=12, ha="center", va="center", color=colors[idx])

ax.scatter(eigenvalues.real, eigenvalues.imag, color='r', marker='x', label='Eigenvalues')
ax.set_title('Gershgorin Circles and Eigenvalues')
ax.set_xlabel('Real')
ax.set_ylabel('Imaginary')
ax.axis('equal')
ax.legend(loc='upper right')
plt.grid(True)
plt.show()

Example usage:

A = np.array([[4, 1, 0, 0], [1, 3, 1, 0], [0, 1, 2, 1], [0, 0, 1, 5]])

plot_gershgorin(A)