# Compute the inverse cosine with scimath in Python

• Last Updated : 01 May, 2022

In this article, we will compute the inverse cosine with scimath in Python using NumPy.

## numpy.arccos 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. 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].

### Example 1:

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.

## Python3

 `import` `numpy as np ` ` `  `# Creating an array ` `array ``=` `np.array([``1``,``2``,``-``3``, ``-``4``]) ` `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 inverse cosine ` `print``(np.emath.arccos(array))`

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]

### Example 2:

In this example, we are taking complex numbers as input to find inverse cosine.

## Python3

 `import` `numpy as np ` ` `  `# Creating an array ` `array ``=` `np.array([``1``-``2j``,``2``+``4j``,``-``3``+``1j``, ``-``4``+``5j``]) ` `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 inverse cosine ` `print``(np.emath.arccos(array))`

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]

My Personal Notes arrow_drop_up
Recommended Articles
Page :