Open In App

Compute the inverse sine with scimath using NumPy in Python

Last Updated : 03 Jun, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will cover how to compute the inverse sine with scimath in Python.

np.emath.arcsin method

A NumPy array can be created in different ways like, by various numbers, and by defining the size of the Array. It can also be created with the use of various data types such as lists, tuples, etc.  NumPy method np.emath.arcsin() method from the numpy package is used to compute the inverse sine with scimath, this method returns the inverse sign of each element of an array passed. Below is the syntax of the arcsin method.

Syntax: numpy.arcsin(x, out=None)

Parameters:

  • x: array like object. 
  • out: ndarray, None, or tuple of ndarray and None, optional

Returns: angle: ndarray. Each element’s inverse sine in x, in radians, and in the closed interval [-pi/2, pi/2]. If x is a scalar, this is a scalar.

Example 1:

In this example, we import the NumPy package and create an array using the np.array() method. The np.emath.arcsin() function is used to find the sine inverse of an element in the array and the information about the array such as shape, datatype, and dimension can be found using the .shape, .dtype, and .ndim attributes. 

Python3




# import packages
import numpy as np
  
# Creating an array
array = np.array([[1,2,3]])
print(array)
  
# shape of the array is
print("Shape of the array is : ",array.shape)
  
# dimension of the array
print("The dimension of the array is : ",array.ndim)
  
# Datatype of the array
print("Datatype of our Array is : ",array.dtype)
  
# computing sine inverse
print(np.emath.arcsin(array))


Output:

[[1 2 3]]

Shape of the array is :  (1, 3)

The dimension of the array is :  2

Datatype of our Array is :  int64

[[1.57079633+0.j         1.57079633+1.3169579j  1.57079633+1.76274717j]]

Example 2:

Here, the output value of ‘1’ refers to pi/2, and ‘-1’ refers to -pi/2. The Sine inverse of 0 is always 0. 

Python3




# import packages
import numpy as np
  
# computing sine inverse
print(np.emath.arcsin(0))
  
# -pi/2
print(np.emath.arcsin(-1))
  
# pi/2
print(np.emath.arcsin(1))


Output:

-1.5707963267948966
1.5707963267948966


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads