Open In App

Ruby | Math cosh() function

Last Updated : 21 Jun, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The cosh() is an inbuilt function in Ruby returns 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

CPP




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


Output:

1.0
1.232972949211241
1.5430806348152437
3.7621956910836314

Example 2

CPP




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


Output:

3.9043355367595756e+56
1.4330863854487745
1.8189854738044024e+42
Infinity

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


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads