The numpy.asinh() function is same as that of numpy.arcsinh() function.
NumPy asinh()
The numpy.asinh()
function computes the inverse hyperbolic sine (also known as the area hyperbolic sine) of each element in an input array.
Syntax
</>
Copy
numpy.asinh(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True)
Parameters
Parameter | Type | Description |
---|---|---|
x | array_like | Input array containing values for which the inverse hyperbolic sine is computed. |
out | ndarray, None, or tuple of ndarray and None, optional | Optional output array where the result is stored. If None, a new array is created. |
where | array_like, optional | Boolean mask specifying which elements to compute. Elements where where=False retain their original value. |
casting | str, optional | Defines the casting behavior when computing the function. |
order | str, optional | Memory layout order of the output array. |
dtype | data-type, optional | Defines the data type of the output array. |
subok | bool, optional | Determines if subclasses of ndarray are preserved in the output. |
Return Value
Returns an array with the inverse hyperbolic sine values of the input elements. If the input is a scalar, a scalar is returned.
Examples
1. Computing asinh of a Single Value
Here, we compute the inverse hyperbolic sine of a single value.
</>
Copy
import numpy as np
# Define a single value
value = 1.0
# Compute the inverse hyperbolic sine of the value
result = np.asinh(value)
# Print the result
print("asinh(1.0):", result)
Output:
asinh(1.0): 0.881373587019543

2. Computing asinh for an Array of Values
We compute the inverse hyperbolic sine for an array of values.
</>
Copy
import numpy as np
# Define an array of values
values = np.array([-2, -1, 0, 1, 2])
# Compute the inverse hyperbolic sine for each value
asinh_values = np.asinh(values)
# Print the results
print("Input values:", values)
print("asinh values:", asinh_values)
Output:
Input values: [-2 -1 0 1 2]
asinh values: [-1.44363548 -0.88137359 0. 0.88137359 1.44363548]

3. Using the out
Parameter
Using an output array to store results instead of creating a new array.
</>
Copy
import numpy as np
# Define an array of values
values = np.array([-1, 0, 1])
# Create an output array with the same shape
output_array = np.ndarray(values.shape)
# Compute inverse hyperbolic sine and store the result in output_array
np.asinh(values, out=output_array)
# Print the results
print("Computed asinh values:", output_array)
Output:
Computed asinh values: [-0.88137359 0. 0.88137359]

4. Using the where
Parameter
Using a condition to compute the inverse hyperbolic sine only for selected elements.
</>
Copy
import numpy as np
# Define an array of values
values = np.array([-2, -1, 0, 1, 2])
# Define a mask (compute asinh only where mask is True)
mask = np.array([True, False, True, False, True])
# Compute inverse hyperbolic sine where mask is True
result = np.asinh(values, where=mask)
# Print the results
print("Computed asinh values with mask:", result)
Output:
Computed asinh values with mask: [-1.44363548e+000 0.00000000e+000 0.00000000e+000 4.95242130e+223
1.44363548e+000]

The asinh values are computed only for elements where mask=True
. The other values remain unchanged.