使用Python中的scimath计算反双曲正切

使用Python中的scimath计算反双曲正切

要使用numpy.emath.arctanh()方法在Python中计算反双曲正切,请使用arctanh。返回arctanh(x)的“主值”。对于绝对值小于1的 实数x,结果是一个实数。如果绝对值大于1或x是复数,结果是复数。最后,x = 1返回“inf”,x = -1返回“-inf”。

该方法返回x值的反双曲正切值。若x是标量,则输出也是标量;否则,返回一个数组。第一个参数是需要计算反双曲正切值的值。

步骤

首先,导入所需的库−

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)

使用Python的numpy.emath.arctanh()方法计算反双曲正切函数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]

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程