Python – scipy.linalg.tanm()


scipy.linalg 包的 tanm() 函式中用於計算輸入矩陣的正切值。該例程使用 expm 來計算矩陣指數。

語法

scipy.linalg.tanm(x)

其中 x 是輸入陣列或方陣。它返回 x 的矩陣正切值。

示例 1

我們考慮以下示例 -

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

# Define the input array
x = np.array([[69 , 12] , [94 , 28]])
print("Input array: \n", x)

# Calculate the Tangent
a = linalg.tanm(x)

# Display the Tangent of matrix
print("Tangent of X: \n", a)

輸出

它將生成以下輸出 -

Input array:
 [[69 12]
 [94 28]]
Tangent of X:
 [[-0.15617321 0.02473695]
 [ 0.19377281 -0.24069113]]

示例 2

我們考慮以下示例 -

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

# Define the input array
y = np.cbrt([[87 , 26] , [59 , 36]])
print("Input array:\n", y)

# Calculate the Tangent
b = linalg.tanm(y)

# Display the Tangent of matrix
print("Tangent of Y: \n", b)

輸出

它將生成以下輸出 -

Input array:
 [[4.43104762 2.96249607]
 [3.89299642 3.30192725]]
Tangent of Y:
 [[1.1489018 0.51580364]
 [0.67781414 0.95230934]]

更新於: 24-Dec-2021

173 瀏覽量

開啟你的 職業生涯

透過學習該課程獲得認證

立即開始
廣告