Open In App

Ruby | Math acosh() function

Last Updated : 07 Jan, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The acosh() is an inbuilt function in Ruby returns the inverse hyperbolic cosine of an angle given in radians.

Syntax: Math.acosh(value)

Parameters: The function accepts one mandatory parameter value which specifies the inverse hyperbolic angle in radian which should be greater or equal to 1. If the argument is less than 1, domain error is returned.

Return Value: The function returns the inverse hyperbolic sine of the argument in radians which is in the range [0, inf].

Example 1:




#Ruby program for acosh() function
  
#Assigning values
val1 = 2 val2 = 877 val3 = 432 val4 = 43
  
#Prints the acosh() value
                                      puts Math.acosh(val1)
                                          puts Math.acosh(val2)
                                              puts Math.acosh(val3)
                                                  puts Math.acosh(val4)


Output:

1.3169578969248166
7.469653847888966
6.761571429209457
4.454212060602711

Example 2:




#Ruby program for acosh() function
  
#Assigning values
val1 = 20 val2 = 83 val3 = 332 val4 = 3
  
#Prints the acosh() value
                                      puts Math.acosh(val1)
                                          puts Math.acosh(val2)
                                              puts Math.acosh(val3)
                                                  puts Math.acosh(val4)


Output:

3.6882538673612966
5.111951496643704
6.498279881360139
1.762747174039086

Reference: https://devdocs.io/ruby~2.5/cmath#method-i-acosh



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads