Ruby | Math cosh() function

The cosh() is an inbuilt function in Ruby returns the the hyperbolic cosine of value given in radians. The value passed is in range [-inf, +inf]. The returned value is in range [1, +inf].

Syntax: Math.cosh(value)

Parameters: The function accepts one mandatory parameter value whose corresponding hyperbolic cosine value is returned.



Return Value: It returns the hyperbolic cosine value.

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby program for cosh() function 
  
# Assigning values
val1 = 0
val2 = 0.67
val3 = 1
val4 = 2
  
# Prints the cosh() value 
puts Math.cosh(val1)
puts Math.cosh(val2)
puts Math.cosh(val3)
puts Math.cosh(val4)

chevron_right


Output:

1.0
1.232972949211241
1.5430806348152437
3.7621956910836314

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# Ruby program for cosh() function 
  
# Assigning values
val1 = 131
val2 = -0.9
val3 = -98
val4 = -767
  
# Prints the cosh() value 
puts Math.cosh(val1)
puts Math.cosh(val2)
puts Math.cosh(val3)
puts Math.cosh(val4)

chevron_right


Output:

3.9043355367595756e+56
1.4330863854487745
1.8189854738044024e+42
Infinity

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



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.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.