tanm() ฟังก์ชันของ scipy.linalg แพ็คเกจใช้เพื่อคำนวณแทนเจนต์ของเมทริกซ์อินพุต กิจวัตรนี้ใช้ 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]]