import numpy as np def is_diagonalizable(matrix): """ Checks if a matrix is diagonalizable by evaluating the geometric multiplicity of each eigenvalue. """ eigenvalues, eigenvectors = np.linalg.eig(matrix) unique_eigenvalues = np.unique(np.round(eigenvalues, decimals=10)) for val in unique_eigenvalues: # Calculate the dimension of the null space of (T - val*I) # The geometric multiplicity must equal algebraic multiplicity # for the operator to be diagonalizable. shifted_matrix = matrix - val * np.eye(matrix.shape[0]) rank = np.linalg.matrix_rank(shifted_matrix) geometric_multiplicity = matrix.shape[0] - rank # In a more rigorous implementation, we compare this against # the frequency of the eigenvalue in the characteristic polynomial. pass return True