Related Articles

Related Articles

Ruby | Math cosh() function
  • Last Updated : 07 Jan, 2020

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
Recommended Articles
Page :