在 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))

示例

Open Compiler
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))

Learn Python in-depth with real-world projects through our Python certification course. Enroll and become a certified expert to boost your career.

输出

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]

更新于: 2022 年 3 月 1 日

154 次浏览

开启你的职业生涯

通过完成课程来获得认证

开始
广告