Eigenvalues and EigenVectors
Let M be an n×n matrix and let X∈Cn be a non-zero vector for which:
MX = λX for some scalar λ.
λ is called an eigenvalue of the matrix M and X is called an eigenvector of M associated with λ, or a λ-eigenvector of M.
Syntax: scipy.linalg.eig(a , b , left , right , overwrite_a , overwrite_b , check_finite , homogeneous_eigvals)
Parameters:
- a: Input matrix.
- b (Optional): It is a right-hand side matrix in a generalized eigenvalue problem.
- left, right (Optional): Whether to compute and return left or right eigenvectors respectively.
- overwrite_a, overwrite_b (Optional): It grants permission to overwrite data in a and b respectively.
- check_finite (Optional): It checks if the input matrix consists of only finite numbers.
- homogeneous_eigvals (Optional): It returns the eigenvalues in homogeneous coordinates if the value is True.
The function scipy.linalg.eig takes a complex or a real matrix M whose eigenvalues and eigenvectors are to be evaluated. It returns the scalar set of eigenvalues for the matrix. It finds the eigenvalues and the right or left eigenvectors of the matrix.
Example:
Python
# Importing the required libraries from scipy import linalg import numpy as np # Initializing the matrix M M = np.array([[ 9 , 3 ] , [ 2 , 4 ]]) # Passing the values to the eigen # function val , vect = linalg.eig(M) # Display the Eigen values and Eigen # vectors print (val) print (vect) |
Output:
SciPy Linear Algebra – SciPy Linalg
The SciPy package includes the features of the NumPy package in Python. It uses NumPy arrays as the fundamental data structure. It has all the features included in the linear algebra of the NumPy module and some extended functionality. It consists of a linalg submodule, and there is an overlap in the functionality provided by the SciPy and NumPy submodules.
Let’s discuss some methods provided by the module and its functionality with some examples.