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