เมธอด numpy.sinh() คำนวณไซน์ไฮเปอร์โบลิกของอาร์เรย์ทีละองค์ประกอบ เทียบเท่า 1/2 * (np.exp(x) - np.exp(-x)) หรือ -1j * np.sin(1j*x)
ขั้นตอนการใช้งาน
import numpy as np
สร้างอาร์เรย์ทดสอบและคำนวณ sinh
arr = np.array((0., 30., 45., 60., 90., 180., np.pi*1j/2, np.pi*1j))
print("Array...\n", arr)
print("\nArray datatype...\n", arr.dtype)
print("\nArray Dimensions...\n", arr.ndim)
print("\nNumber of elements in the Array...\n", arr.size)
print("\nResult...", np.sinh(arr))
โค้ดตัวอย่างสมบูรณ์
import numpy as np
arr = np.array((0., 30., 45., 60., 90., 180., np.pi*1j/2, np.pi*1j))
print("Array...\n", arr)
print("\nOur Array type...\n", arr.dtype)
print("\nOur Array Dimensions...\n", arr.ndim)
print("\nNumber of elements...\n", arr.size)
print("\nResult...", np.sinh(arr))
ผลลัพธ์ที่คาดหวัง
Get the Trigonometric Hyperbolic sine of the array elements... Array... [ 0.+0.j 30.+0.j 45.+0.j 60.+0.j 90.+0.j 180.+0.j 0.+1.57079633j 0.+3.14159265j] Our Array type... complex128 Our Array Dimensions... 1 Number of elements... 8 Result... [ 0.00000000e+00+0.j 5.34323729e+12+0.j 1.74671355e+19+0.j 5.71003695e+25+0.j 6.10201647e+38+0.j 7.44692100e+77+0.j 0.00000000e+00+1.j -0.00000000e+00+1.2246468e-16j]