在 Python 中使用 scimath 计算反正弦
要在 Python 中使用 scimath 计算反正弦,请使用 numpy.emath.arcsin() 方法。这会返回 x 反正弦的“主值”。对于 abs(x) <= 1 的实际 x,这是一个在闭区间 [-π/2, π/2] 内的实数。否则,将返回复杂的主值。
该方法返回 x 值的反函数正弦。如果 x 是标量,out 也是标量,否则将返回一个数组对象。第一个参数是要计算其反正弦值。
步骤
首先,导入所需的库 -
import numpy as np
使用 array() 方法创建 numpy 数组 -
arr = np.array([0, 1, -1, 2])
显示数组 -
print("Array...\n", arr)获取数组的类型 -
print("\nOur Array type...\n", arr.dtype)
获取数组的维度 -
print("\nOur Array Dimensions...\n",arr.ndim)要在 Python 中使用 scimath 计算反正弦,请使用 numpy.emath.arcsin() 方法 -
print("\nResult...",np.emath.arcsin(arr))示例
import numpy as np
# Create a numpy array using the array() method
arr = np.array([0, 1, -1, 2])
# 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 sine with scimath, use the numpy.emath.arcsin() method in Python
print("\nResult...",np.emath.arcsin(arr))输出
Array... [ 0 1 -1 2] Our Array type... int64 Our Array Dimensions... 1 Number of elements... 4 Result... [ 0. +0.j 1.57079633+0.j -1.57079633+0.j 1.57079633+1.3169579j]
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C #
MongoDB
MySQL
Javascript
PHP