![]() |
VOOZH | about |
In this article, we will compute the inverse cosine with scimath in Python using NumPy.
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. The np.emath.arccos() method from the NumPy package is used to compute the inverse cosine with scimath in python. Below is the syntax of the arccos method.
Syntax: numpy.arccos(x, out=None, where=True)
Parameters:
- x: array_like
- out: tuple of ndarray(optional)
Return: return the angle z whose real part lies in [0, pi].
Here, we will create a NumPy array and use np.emath.arccos() to compute the inverse cosine for the given values. The shape of the array is found by the .shape attribute, the dimension of the array is found by .ndim attribute, and the data type of the array is .dtype attribute.
Output:
[ 1 2 -3 -4]
Shape of the array is : (4,)
The dimension of the array is : 1
Datatype of our Array is : int64
[0. -0.j 0. -1.3169579j 3.14159265-1.76274717j
3.14159265-2.06343707j]
In this example, we are taking complex numbers as input to find inverse cosine.
Output:
[ 1.-2.j 2.+4.j -3.+1.j -4.+5.j]
Shape of the array is : (4,)
The dimension of the array is : 1
Datatype of our Array is : complex128
[1.14371774+1.52857092j 1.11692612-2.19857303j 2.80389154-1.8241987j
2.2396129 -2.55132163j]