Python - scipy.linalg.expm
scipy.linalg 包的 expm() 函数用于使用帕德近似计算矩阵指数。帕德逼近是按既定阶的理函数对函数进行的“最优”逼近。在此技术下,逼近式的幂级数与它逼近的函数的幂级数相符。
语法
scipy.linalg.expm(x)
其中 x 是要进行指数运算的输入矩阵。
示例 1
让我们考虑以下示例 −
# Import the required libraries
from scipy import linalg
import numpy as np
# Define the input array
e = np.array([[100 , 5] , [78 , 36]])
print("Input Array :\n", e)
# Calculate the exponential
m = linalg.expm(e)
# Display the exponential of matrix
print("Exponential of e: \n", m)输出
上述程序将生成以下输出 −
Input Array : [[100 5] [ 78 36]] Exponential of e: [[6.74928440e+45 4.84840154e+44] [7.56350640e+45 5.43330432e+44]]
示例 2
让我们再举一个示例 −
# Import the required libraries
from scipy import linalg
import numpy as np
# Define the input array
k = np.zeros((3, 3))
print("Input Array :\n", k)
# Calculate the exponential
n = linalg.expm(k)
# Display the exponential of matrix
print("Exponential of k: \n", n)输出
它将生成以下输出 −
Input Array : [[0. 0. 0.] [0. 0. 0.] [0. 0. 0.]] Exponential of k: [[1. 0. 0.] [0. 1. 0.] [0. 0. 1.]]
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP