Code Explanation:
1. Importing Required Libraries
from scipy.linalg import eig
import numpy as np
scipy.linalg.eig: This function is used to compute the eigenvalues and eigenvectors of a square matrix.
numpy (np): A fundamental package for numerical computations in Python.
2. Defining the Matrix A
A = np.array([[0, -1], [1, 0]])
This matrix represents a 90-degree rotation in 2D space.
3. Computing Eigenvalues
eigenvalues, _ = eig(A)
eig(A): Computes the eigenvalues and eigenvectors of matrix A.
eigenvalues: The roots of the characteristic equation
det(A−λI)=0.
_: We use _ as a placeholder since we are not interested in the eigenvectors.
4. Printing the Eigenvalues
print(eigenvalues)
The output will be:
Final Output:
[1j ,-1j]
0 Comments:
Post a Comment