This is a detailed tutorial of the NumPy Hyperbolic Universal Functions. Learn the usage of these functions with the help of examples.
Table of Contents
Hyperbolic Functions
These are those function which takes value in the radians ad will give us alternative values for sin, cos and tan. The Unfuncs provide us with sinh()
, cosh()
and tanh()
the functions which help in this process. These are very helpful in explaining various real-life curves.
Let us take an example:
#first we will import the numpy package import numpy as np #now in the next step we use sinh() function a=np.sinh(np.pi/4) #now we will print the result print(a)
Output.
0.868670961486
Now let us take an example where we will find the hyperbolic values for elements in the array:
#first we will import the numpy package import numpy as np #now in the next step we use sinh() function a=np.array([np.pi/4,np.pi/1,np.pi/7,np.pi/6]) b=np.sinh(a) #now we will print the result print(b)
Output.
[ 0.86867096 11.54873936 0.46401763 0.54785347]
Finding Angles
In order to find angles form the values of hyperbolic sin, cos, tan, we need to have the inverse of these values. In NumPy, we have some Unfuncs which help us getting the radians’ values for these. These functions are as follow. arcsinh()
, arccosh()
and arctanh()
.
Let us take an example to understand it better:
#first we will import the numpy package import numpy as np #now in the next step we use arcsinh() function a=np.arcsinh(np.pi/4) #now we will print the result print(a)
Output.
0.721225488727
we will take another example to find for cosh and tanh:
#first we will import the numpy package import numpy as np #now in the next step we use arccosh() function a=np.arccosh(1.0) #now we will print the result print(a)
Output.
0.0
Another example:
#first we will import the numpy package import numpy as np #now in the next step we use arctanh() function a=np.arctanh(0.5) #now we will print the result print(a)
Output.
0.549306144334
Angles of Values
In order to find the angles of the values which we pass in an array, let us take an example to understand this concept.
#first we will import the numpy package import numpy as np #now in the next step we use arcsinh() function a=np.array([0.2,0.5]) b=np.arcsinh(a) #now we will print the result print(b)
Output.
[ 0.19869011 0.48121183]
I hope you found this guide useful. If so, do share it with others who are willing to learn Numpy and Python. If you have any questions related to this article, feel free to ask us in the comments section.
And do not forget to subscribe to WTMatter!