红宝石 |数学 cosh()函数
cosh()是 Ruby 中的内置函数,返回以弧度给出的值的双曲余弦值。传递的值在[-inf, +inf]范围内。返回值在[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.
示例 1 :
# 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)
输出:
1.0
1.232972949211241
1.5430806348152437
3.7621956910836314
示例 2 :
# 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)
输出:
3.9043355367595756e+56
1.4330863854487745
1.8189854738044024e+42
Infinity
参考:https://devdocs.io/ruby~2.5/math#method-c-cosh