More Matrix Functions
Function Name | Definition |
---|---|
scipy.linalg.sqrtm(A, disp, blocksize) | Finds the square root of the matrix. |
scipy.linalg.expm(A) | Computes the matrix exponential using Pade approximation. |
scipy.linalg.sinm(A) | Computes the sine of the matrix. |
scipy.linalg.cosm(A) | Computes the cosine of the matrix. |
scipy.linalg.tanm(A) | Computes the tangent of the matrix. |
Example:
Python
# Importing the required libraries from scipy import linalg import numpy as np # Initializing the matrix x = np.array([[ 16 , 4 ] , [ 100 , 25 ]]) # Calculate and print the matrix # square root r = linalg.sqrtm(x) print (r) print ( "\n" ) # Calculate and print the matrix # exponential e = linalg.expm(x) print (e) print ( "\n" ) # Calculate and print the matrix # sine s = linalg.sinm(x) print (s) print ( "\n" ) # Calculate and print the matrix # cosine c = linalg.cosm(x) print (c) print ( "\n" ) # Calculate and print the matrix # tangent t = linalg.tanm(x) print (t) |
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.