Overview:
- The function eig() from the linalg module of NumPy library computes the eigenvalues and eigenvectors of a given square matrix.
Example:
# Example Python program that finds the eigenvectors and eigenvalues # Printing format of floating point numbers # Generate matrix elements # Create matrix # Find the eigen values and eigen vectors of the matrix print("Eigenvalues:") print("Eigenvectors:") |
Output:
A 4x4 matrix: [[-15 -13 -11 -9] [ -7 -5 -3 -1] [ 1 3 5 7] [ 9 11 13 15]] Eigenvalues: [-17.89 0.00 17.89 -0.00] Eigenvectors: [[0.82 0.55 0.38 -0.43] [0.42 -0.73 -0.02 0.83] [0.02 -0.18 -0.42 -0.35] [-0.38 0.37 -0.82 -0.04]] |