NumPy Arcsinh – A Complete Guide

NumPy Arcsinh

Welcome to another exciting tutorial on NumPy arcsinh function. Here, we will understand the NumPy arcsinh function in detail. Without any further due let’s get started!

Also read: Numpy sinh – Hyperbolic sine, element-wise

What is Hyperbolic arcsin (inverse sine)? Quick overview

  • arcsinh is the inverse hyperbolic sine function.
  • The equivalent expression for arcsinh is:
Arcsinh Equivalent Expression
Arcsinh Equivalent Expression
  • The domain of the arcsinh function is a set of Real Numbers.
  • The range of the arcsinh function is also a set of Real Numbers.

What is NumPy.arcsinh()?

NumPy arcsinh is one of the Inverse hyperbolic functions provided by the NumPy Library. It takes a single number, a complex number as well as a NumPy array of numbers as input.

The NumPy arcsinh function can be accessed as numpy.arcsinh().

Syntax: numpy.arcsinh(input) where input can be a single number, a complex number as well as a NumPy array of numbers.

Working with NumPy Arcsinh

Let’s write some code to understand the arcsinh function better.

Using numpy.arcsinh() function with a NumPy array having numbers

import numpy as np

a = np.array((0 , 2 , 3 , 10 , 90 , 100))

arcsinh_values = np.arcsinh(a)

print("Input Array: \n",a)

print("Arcsinh Values:\n",arcsinh_values)

Output

Input Array: 
 [  0   2   3  10  90 100]
Arcsinh Values:
 [0.         1.44363548 1.81844646 2.99822295 5.19298771 5.29834237]

If you are wondering how these values are calculated you can simply put the values of the input array in the equivalent expression of the arcsinh function discussed in Arcsinh – A Quick Overview section.

Let’s try passing some pi values to the arcsinh function.

Using numpy.arcsinh() with a NumPy array having angles in Radians

import numpy as np

a = np.array((np.pi/2 , np.pi/4 , np.pi/6 , 3*np.pi/2))

arcsinh_values = np.arcsinh(a)

print("Input Array :\n",a)

print("Arcsinh values :\n",arcsinh_values)

Output

Input Array :
 [1.57079633 0.78539816 0.52359878 4.71238898]
Arcsinh values :
 [1.23340312 0.72122549 0.50221899 2.25441459]

Task: Try using the arcsinh function with Euler’s number i.e. numpy.e the value of Euler’s constant is 2.718281828.

NumPy Arcsinh with Complex Number

import numpy as np

print("The arcsinh value of 1+2j is: \n",np.arcsinh(1+2j))

print("The arcsinh value of -1+3j is: \n",np.arcsinh(-1+3j))

Output

The arcsinh value of 1+2j is: 
 (1.4693517443681852+1.0634400235777521j)
The arcsinh value of -1+3j is:
 (-1.8241987021938828+1.2330952175293441j)

Note: If a number cannot be represented as a real number or infinity, it returns nan.

That was all about using the arcsinh function with different values. Now, let’s plot the arcsinh function using the Matplotlib library in python.

Visualizing the Arcsinh function

import numpy as np

# Importing the Matplolib library
import matplotlib.pyplot as plt

a = np.linspace(-4 , 4 , 50)

# Storing the arcsinh values
b = np.arcsinh(a)

plt.plot(a , b , color = "blue" , marker = "o")

plt.title("numpy.arcsinh()")
plt.xlabel("X")
plt.ylabel("Y")

plt.show()

Output

Arcsinh Plot
Arcsinh Plot

You have successfully plotted the arcsinh function.

Conclusion

That was all about the arcsinh function, this function is really simple to understand and easy to use. In the next tutorial, we will cover the NumPy Arccosh function in detail. Till then stay tuned 🙂

References