NumPy arccosh() Function:
The arccosh() function of the NumPy module computes the inverse hyperbolic cosine of the array elements.
The inverse hyperbolic cosine of x is calculated as follows:
Syntax:
numpy.arccosh(array, out=None)
Parameters
array: This is required. The array items for which the inverse hyperbolic cosine values are to be computed. The absolute value of each array item should be greater than 1.
out: This is optional.The output array’s shape. It is the location where the result will be stored. It must have a shape that the inputs broadcast to if it is provided. If None or not given, a newly allocated array is returned.
Return value
The inverse hyperbolic cosine value of each element of the given array is returned.
NumPy arccosh() Function in Python
Example#1: Using Built-in Functions (Static Input)
Approach:
- Import numpy module using the import keyword.
- Give the array as static input using the array() function of the numpy module by passing some random list of numbers as an argument to it.
- Store it in a variable.
- Calculate the inverse hyperbolic cosine values of the given array using the arccosh() function of the Numpy module and store it in another variable.
- Print the inverse hyperbolic cosine values of the given array.
- The Exit of the Program.
Below is the implementation:
# Import numpy module using the import keyword import numpy as np # Give the array as static input using the array() function by passing some # random list of numbers as an argument to it. # Store it in another variable gvn_arry = np.array([2, 5, 6, 1]) # Calculate the inverse hyperbolic cosine values of the given array # using the arccosh() function of the numpy module and store it in another variable rslt= np.arccosh(gvn_arry) # Print the inverse hyperbolic cosine values of the given array print("The inverse hyperbolic cosine values of the given array = ") print(rslt)
Output:
The inverse hyperbolic cosine values of the given array = [1.3169579 2.29243167 2.47788873 0. ]
Example#2: Using Built-in Functions (User Input)
Approach:
- Import numpy module using the import keyword.
- Give the list as user input using the list(),map(),split(),int functions and store it in a variable.
- Pass the above list as an argument to the array() function to get an array.
- Store it in another variable.
- Calculate the inverse hyperbolic cosine values of the given array using the arccosh() function of the Numpy module and store it in another variable.
- Print the inverse hyperbolic cosine values of the given array.
- The Exit of the Program.
Below is the implementation:
# Import numpy module using the import keyword import numpy as np # Give the list as user input using the list(),map(),split(),int functions # and store it in a variable. gvn_lst = list(map(int, input( 'Enter some random List Elements separated by spaces = ').split())) # Pass the above list as an argument to the array() function to get an array. # Store it in another variable gvn_arry = np.array(gvn_lst) # Calculate the inverse hyperbolic cosine values of the given array # using the arccosh() function of the numpy module and store it in another variable rslt= np.arccosh(gvn_arry) # Print the inverse hyperbolic cosine values of the given array print("The inverse hyperbolic cosine values of the given array = ") print(rslt)
Output:
Enter some random List Elements separated by spaces = 10 45 6 60 The inverse hyperbolic cosine values of the given array = [2.99322285 4.49968619 2.47788873 4.78742229]