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