Ruby | Math atanh() function
The atanh() is an inbuilt function in Ruby returns the inverse hyperbolic tangent of an angle given in radians. It accepts values in the range [-1, +1] and returns in the range [-INFINITY, INFINITY].
Syntax: Math.atanh(value)
Parameters: The function accepts one mandatory parameter value which specifies the inverse hyperbolic angle in radian which lies in the range [-1, 1].
Return Value: It returns the inverse hyperbolic tangent of an angle given in radians
Example 1:
#Ruby program for atanh() function
#Assigning values
val1 = -1 val2 = 1 val3 = -0.5 val4 = 0.7
#Prints the atanh() value
puts Math.atanh(val1)
puts Math.atanh(val2)
puts Math.atanh(val3)
puts Math.atanh(val4)
|
Output:
-Infinity
Infinity
-0.5493061443340548
0.8673005276940531
Example 2:
#Ruby program for atanh() function
#Assigning values
val1 = -0.7 val2 = 0.6 val3 = -0.56 val4 = 0.90
#Prints the atanh() value
puts Math.atanh(val1)
puts Math.atanh(val2)
puts Math.atanh(val3)
puts Math.atanh(val4)
|
Output:
-0.8673005276940531
0.6931471805599453
-0.632833186665638
1.4722194895832204
Reference: https://devdocs.io/ruby~2.5/math#method-c-atanh
Last Updated :
07 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...