在 Python 中使用 scimath 計算雙曲反正切函式
要使用 arctanh 計算雙曲反正切函式,請在 Python 中使用 numpy.emath.arctanh() 方法。返回 arctanh(x) 的“主值”。對於 abs(x) < 1 的實數 x,這是一個實數。如果 abs(x) > 1 或者 x 是複數,結果是複數。最後,x = 1 返回``inf``,x=-1 返回 -inf。
該方法返回 x 值的雙曲反正切。如果 x 是標量,out 也是,否則會返回一個數組。第一個引數是要計算其 arctanh 的值。
步驟
首先,匯入必需的庫 −
import numpy as np
使用 array() 方法建立一個 numpy 陣列 −
arr = np.array([0, 1j, 2j])
顯示陣列 −
print("Array...\n", arr)獲取陣列的型別 −
print("\nOur Array type...\n", arr.dtype)
獲取陣列的維度 −
print("\nOur Array Dimensions...\n",arr.ndim)要使用 arctanh 計算雙曲反正切函式,請在 Python 中使用 numpy.emath.arctanh() 方法 −
print("\nResult...\n",np.emath.arctanh(arr))
示例
import numpy as np
# Create a numpy array using the array() method
arr = np.array([0, 1j, 2j])
# Display the array
print("Array...\n", arr)
# Get the type of the array
print("\nOur Array type...\n", arr.dtype)
# Get the dimensions of the Array
print("\nOur Array Dimensions...\n",arr.ndim)
# Get the number of elements in the Array
print("\nNumber of elements...\n", arr.size)
# To compute the inverse hyperbolic tangent with arctanh, use the numpy.emath.arctanh() method in Python
print("\nResult...\n",np.emath.arctanh(arr))輸出
Array... [0.+0.j 0.+1.j 0.+2.j] Our Array type... complex128 Our Array Dimensions... 1 Number of elements... 3 Result... [0.+0.j 0.+0.78539816j 0.+1.10714872j]
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP