在 Python 中計算反雙曲餘弦
arccosh() 是一個多值函式:對於每個 x,都有無限多個數字 z 使得 cosh(z) = x。慣例是返回虛部位於 [-pi, pi] 且實部位於 [0, inf] 的 z。對於實數值輸入資料型別,arccosh 始終返回實數輸出。對於每個不能表示為實數或無窮大的值,它會產生 nan 並設定無效浮點錯誤標誌。對於複數值輸入,arccosh 是一個復解析函式,它有一個分支切割 [-inf, 1] 並在其上從上方連續。
要計算反雙曲餘弦,請在 Python Numpy 中使用 numpy.arccosh() 方法。該方法返回與 x 形狀相同的陣列。如果 x 是標量,則為標量。第一個引數 x 是輸入陣列。第二個和第三個引數是可選的。
第二個引數是 ndarray,結果儲存到的位置。如果提供,則其形狀必須是輸入廣播到的形狀。如果未提供或為 None,則返回一個新分配的陣列。第三個引數是條件在輸入上廣播。在條件為 True 的位置,out 陣列將設定為 ufunc 結果。在其他地方,out 陣列將保留其原始值。
步驟
首先,匯入所需的庫 -
import numpy as np
查詢 arccosh -
print("\nResult...",np.arccosh(np.pi*1j))
查詢 90 度的 arccosh -
print("\nResult...",np.arccosh(np.pi/2.))查詢 60 度的 arccosh -
print("\nResult...",np.arccosh(np.pi/3.))
查詢 np.e 的 arccosh -
print("\nResult...",np.arccosh(np.e))示例
import numpy as np
# To compute the inverse Hyperbolic cosine, use the numpy.arccosh() method in Python Numpy
# The method returns the array of the same shape as x. This is a scalar if x is a scalar.
print("Get the Trigonometric inverse Hyperbolic cosine...")
# find arccosh
print("\nResult...",np.arccosh(np.pi*1j))
# finding arccosh 90 degrees
print("\nResult...",np.arccosh(np.pi/2.))
# finding arccosh 60 degrees
print("\nResult...",np.arccosh(np.pi/3.))
# finding arccosh np.e
print("\nResult...",np.arccosh(np.e))輸出
Get the Trigonometric inverse Hyperbolic cosine... Result... (1.8622957433108482+1.5707963267948966j) Result... 1.0232274785475506 Result... 0.30604210861326536 Result... 1.6574544541530771
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP