
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Compute the inverse cosine with scimath in Python
To compute the inverse cosine with scimath, use the numpy.emath.arccos() method in Python. Return the “principal value” of the inverse cosine of x. For real x such that abs(x) <= 1, this is a real number in the closed interval [0,π]. Otherwise, the complex principle value is returned.
The method returns the inverse cosine(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 arccos 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([1, -1, 2, 0])
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 Dimension...\n",arr.ndim)
To compute the inverse cosine with scimath, use the numpy.emath.arccos() method in Python −
print("\nResult...",np.emath.arccos(arr))
Example
import numpy as np # Create a numpy array using the array() method arr = np.array([1, -1, 2, 0]) # 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 cosine with scimath, use the numpy.emath.arccos() method in Python print("\nResult...",np.emath.arccos(arr))
Output
Array... [ 1 -1 2 0] Our Array type... int64 Our Array Dimensions... 1 Number of elements... 4 Result... [0. -0.j 3.14159265-0.j 0. -1.3169579j 1.57079633-0.j ]
- Related Articles
- Compute the inverse sine with scimath in Python
- Compute the inverse hyperbolic tangent with scimath in Python
- Compute the inverse Hyperbolic cosine in Python
- How to compute the inverse cosine and inverse hyperbolic cosine in PyTorch?
- Compute the inverse Hyperbolic cosine of array elements in Python
- Compute the natural logarithm with scimath in Python
- Compute the logarithm base 2 with scimath in Python
- Compute the logarithm base n with scimath in Python
- Compute the logarithm base 10 with scimath in Python
- Get the Trigonometric inverse cosine in Python
- Compute the Hyperbolic cosine in Python
- Compute the square root of complex inputs with scimath in Python
- Compute the inverse Hyperbolic sine in Python
- Compute the inverse Hyperbolic tangent in Python
- Get the Trigonometric inverse cosine of the array elements in Python

Advertisements