在 Python 中計算反雙曲正切
arctanh 是一個多值函式:對於每個 x,都有無限多個數字 z 使得 tanh(z) = x。慣例是返回其虛部位於 [-pi/2, pi/2] 之間的 z。反雙曲正切也稱為 atanh 或 tanh^-1。
要計算反雙曲正切,請使用 numpy.arctanh() 方法。該方法返回與 x 形狀相同的陣列。如果 x 是標量,則為標量。第一個引數 x 是輸入陣列。第二個和第三個引數是可選的。
第二個引數是 ndarray,結果儲存在其中的位置。如果提供,則其形狀必須與輸入廣播到的形狀相同。如果未提供或為 None,則返回一個新分配的陣列。
第三個引數是條件在輸入上廣播。在條件為 True 的位置,out 陣列將設定為 ufunc 結果。在其他地方,out 陣列將保留其原始值。
步驟
首先,匯入所需的庫 -
import numpy as np
查詢 arctanh 0 -
print("\nResult...",np.arctanh(0))
查詢 arctanh 0.3 -
print("\nResult...",np.arctanh(0.3))查詢 arctanh -0.3 -
print("\nResult...",np.arctanh(-0.3))
查詢 arctanh 0.5 -
print("\nResult...",np.arctanh(0.5))查詢 arctanh 0.11 -
print("\nResult...",np.arctanh(0.11))
示例
import numpy as np
# The arctanh is a multivalued function: for each x there are infinitely many numbers z such that tanh(z) = x. The convention is to return the z whose imaginary part lies in [-pi/2, pi/2].
# The inverse hyperbolic tangent is also known as atanh or tanh^-1.
print("Get the Trigonometric inverse Hyperbolic tangent...")
# find arctanh 0
print("\nResult...",np.arctanh(0))
# finding arctanh 0.3
print("\nResult...",np.arctanh(0.3))
# finding arctanh -0.3
print("\nResult...",np.arctanh(-0.3))
# finding arctanh 0.5
print("\nResult...",np.arctanh(0.5))
# finding arctanh 0.11
print("\nResult...",np.arctanh(0.11))輸出
Get the Trigonometric inverse Hyperbolic tangent... Result... 0.0 Result... 0.30951960420311175 Result... -0.30951960420311175 Result... 0.5493061443340548 Result... 0.11044691579009715
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP