NumPy arcsinh() Function



The NumPy arcsinh() function is used to compute the inverse hyperbolic sine (arcsine hyperbolic) of each element in an input array. It calculates the value of the angle (in radians) whose hyperbolic sine is the input value.

  • Domain: The function accepts input values for all real numbers, including both positive and negative values.
  • Range: The output values are in the range of all real numbers, as the arcsinh function can return any real number.

Syntax

Following is the syntax of the NumPy arcsinh() function −

numpy.arcsinh(x, /, out=None, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])

Parameters

This function accepts the following parameters −

  • x: The input array or scalar. The function computes the inverse hyperbolic sine of each element of the array or scalar.
  • out (optional): 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.
  • where (optional): This condition is broadcast over the input. At locations where the condition is True, the result will be computed. Otherwise, the result will retain its original value.
  • casting (optional): Controls what kind of data casting may occur. Defaults to 'same_kind'.
  • order (optional): Controls the memory layout order of the result. 'C' means C-order, 'F' means Fortran-order, 'A' means 'F' if inputs are all F, 'C' otherwise, 'K' means match the layout of the inputs as closely as possible.
  • dtype (optional): The type of the returned array and of the accumulator in which the elements are processed. The dtype of x is used by default unless dtype is specified.
  • subok (optional): If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array.

Return Value

This function returns an array where each element is the inverse hyperbolic sine (arcsine hyperbolic) of the corresponding element in the input array x, in radians.

Example: Basic Usage of arcsinh() Function

In the following example, we use the arcsinh() function to compute the inverse hyperbolic sine of each element in a 1-dimensional array −

import numpy as np

# Creating a 1-dimensional array
arr = np.array([-1, 0, 1, 2])

# Applying arcsinh to each element
result = np.arcsinh(arr)
print(result)

The output obtained will be −

[-0.88137359  0.          0.88137359  1.44363548]

Example: Arcsine of Angles in Degrees

In this example, we first calculate the inverse hyperbolic sine in radians and then convert the result to degrees using numpy.degrees() function −

import numpy as np

# Creating an array of values
values = np.array([-1, 0, 1, 2])

# Calculate arcsinh in radians
radians_result = np.arcsinh(values)

# Convert radians to degrees
degrees_result = np.degrees(radians_result)
print(degrees_result)

This will produce the following result −

[-50.74829826   0.           50.49898671  82.71421988]

Example: Arcsine of a Single Scalar Value

In the example below, we are using the arcsinh() function to calculate the inverse hyperbolic sine of a single scalar value −

import numpy as np

# Scalar value
scalar = 1

# Applying arcsinh to the scalar
result = np.arcsinh(scalar)
print(result)

The output obtained is −

0.881373587019543

Example: Arcsine of Negative Values

The arcsinh function returns negative angles for negative inputs. Here, we calculate the inverse hyperbolic sine of negative values −

import numpy as np

# Negative values
negative_values = np.array([-2, -1, -0.5])

# Applying arcsinh to the array
result = np.arcsinh(negative_values)
print(result)

This will produce the following result −

[-1.44363548 -0.88137359 -0.48121183]
numpy_trigonometric_functions.htm
Advertisements