Compute the inverse Hyperbolic cosine in Python


The arccosh() is a multivalued function: for each x there are infinitely many numbers z such that cosh(z) = x. The convention is to return the z whose imaginary part lies in [-pi, pi] and the real part in [0, inf]. For real-valued input data types, arccosh always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag. For complex-valued input, arccosh is a complex analytical function that has a branch cut [-inf, 1] and is continuous from above on it.

To compute the inverse Hyperbolic cosine, use the numpy.arccosh() method in Python Numpy. The method returns the array of the same shape as x. This is a scalar if x is a scalar. The 1st parameter, x is input array. The 2nd and 3rd parameters are optional.

The 2nd parameter is an ndarray, A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. The 3rd parameter is the condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value.

Steps

At first, import the required library −

import numpy as np

Find arccosh −

print("\nResult...",np.arccosh(np.pi*1j))

Finding arccosh 90 degrees −

print("\nResult...",np.arccosh(np.pi/2.))

Finding arccosh 60 degrees −

print("\nResult...",np.arccosh(np.pi/3.))

Finding arccosh np.e −

print("\nResult...",np.arccosh(np.e))

Example

import numpy as np

# To compute the inverse Hyperbolic cosine, use the numpy.arccosh() method in Python Numpy
# The method returns the array of the same shape as x. This is a scalar if x is a scalar.

print("Get the Trigonometric inverse Hyperbolic cosine...")

# find arccosh
print("\nResult...",np.arccosh(np.pi*1j))

# finding arccosh 90 degrees
print("\nResult...",np.arccosh(np.pi/2.))

# finding arccosh 60 degrees
print("\nResult...",np.arccosh(np.pi/3.))

# finding arccosh np.e
print("\nResult...",np.arccosh(np.e))

Output

Get the Trigonometric inverse Hyperbolic cosine...

Result... (1.8622957433108482+1.5707963267948966j)

Result... 1.0232274785475506

Result... 0.30604210861326536

Result... 1.6574544541530771

Updated on: 25-Feb-2022

335 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements