在 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