Python – scipy.linalg.sinm()


scipy.linalg 包中的 sinm() 函式用於計算輸入矩陣的正弦。此例程使用 expm 計算矩陣指數。

語法

scipy.linalg.sinm(x)

其中 x 是輸入陣列。

示例 1

讓我們考慮以下示例 −

# Import the required libraries from scipy
from scipy import linalg
import numpy as np

# Define the input array
X = np.array([[110, 12], [79, 23]])
print("Input Matrix, X:\n", X)

# Calculate the Sine of the matrix
n = linalg.sinm(X)

# Display the Sine
print("Sine of X: \n", n)

輸出

它將生成以下輸出 −

Input Matrix, X:
 [[110 12]
 [ 79 23]]
Sine of X:
 [[ 0.41972171 -0.02196579]
 [-0.14460811 0.57897368]]

示例 2

讓我們再來看一個示例 −

# Import the required libraries
from scipy import linalg
import numpy as np

# Define the input array
p = np.array([[87 , 15] , [48 , 12]])
q = linalg.inv(p)
print("Input Matrix:\n", q)

# Calculate the Sine
n = linalg.sinm(q)

# Display the Sine of matrix
print("Sine of Q: \n", n)

輸出

它將生成以下輸出 −

Input Matrix:
 [[ 0.03703704 -0.0462963 ]
 [-0.14814815 0.26851852]]
Sine of Q:
 [[ 0.03663868 -0.04560274]
 [-0.14592875 0.26465236]]

更新於: 24-12-2021

180 檢視

啟動您的職業生涯

完成課程獲得認證

開始
廣告