Compute the inverse sine with scimath in Python


To compute the inverse sine with scimath, use the numpy.emath.arcsin() method in Python. Returns the “principal value” of the inverse sine of x. For real x such that abs(x) <= 1, this is a real number in the closed interval [-π/2, π/2]. Otherwise, the complex principle value is returned.

The method returns the inverse sine(s) of the x value(s). If x was a scalar, so is out, otherwise an array object is returned. The 1st parameter is the value(s) whose arcsin is (are) required.

Steps

At first, import the required libraries −

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)

To compute the inverse sine with scimath, use the numpy.emath.arcsin() method in Python −

print("\nResult...",np.emath.arcsin(arr))

Example

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

Output

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]

Updated on: 01-Mar-2022

116 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements