Calculate the eigenvalues of a square matrix.
Eigenvalue Definition:
Av=λvCharacteristic Equation:
det(A−λI)=0Where: A = matrix, λ = eigenvalue, v = eigenvector, I = identity matrix, det = determinant
matrix: list[list[float]] | np.ndarray - Input matrix (should be square)Input: matrix=[[4, 1], [2, 3]]
Output: [2.0, 5.0] (approximately)
Input: matrix=[[0, -1], [1, 0]]
Output: [-1j, 1j] (pure imaginary)
Input: matrix=[[1, 2, 3], [4, 5]]
Output: None (non-square)
Use np.asarray() to convert input to numpy array. Check matrix dimensions with .shape and .ndim.
Use np.linalg.eigvals() to compute eigenvalues. Use np.lexsort() for consistent sorting by real then imaginary parts.
Handle edge cases: check if matrix is square with matrix.shape[0] == matrix.shape[1]. Return None for invalid inputs.
np.ndarray of eigenvalues (complex dtype if needed)None for non-square matrices or invalid inputSign in to take notes on this problem
Accepts: array
Calculate the eigenvalues of a square matrix.
Eigenvalue Definition:
Av=λvCharacteristic Equation:
det(A−λI)=0Where: A = matrix, λ = eigenvalue, v = eigenvector, I = identity matrix, det = determinant
matrix: list[list[float]] | np.ndarray - Input matrix (should be square)Input: matrix=[[4, 1], [2, 3]]
Output: [2.0, 5.0] (approximately)
Input: matrix=[[0, -1], [1, 0]]
Output: [-1j, 1j] (pure imaginary)
Input: matrix=[[1, 2, 3], [4, 5]]
Output: None (non-square)
Use np.asarray() to convert input to numpy array. Check matrix dimensions with .shape and .ndim.
Use np.linalg.eigvals() to compute eigenvalues. Use np.lexsort() for consistent sorting by real then imaginary parts.
Handle edge cases: check if matrix is square with matrix.shape[0] == matrix.shape[1]. Return None for invalid inputs.
np.ndarray of eigenvalues (complex dtype if needed)None for non-square matrices or invalid inputSign in to take notes on this problem
Accepts: array