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:

filter_none

edit
close

play_arrow

link
brightness_4
code

#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)

chevron_right


Output:

 -Infinity
Infinity
-0.5493061443340548
0.8673005276940531

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

#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)

chevron_right


Output:

-0.8673005276940531
0.6931471805599453
-0.632833186665638
1.4722194895832204

Reference: https://devdocs.io/ruby~2.5/math#method-c-atanh



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.