cosh()是Ruby中的內置函數,返回以弧度給出的雙曲餘弦值。傳遞的值在[-inf,+ inf]範圍內。返回的值在[1,+ inf]範圍內。
用法: Math.cosh(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
相關用法
- Ruby Math erf()用法及代碼示例
- Ruby Math sin()用法及代碼示例
- Ruby Math log()用法及代碼示例
- Ruby Math exp()用法及代碼示例
- Ruby Math cos()用法及代碼示例
- Ruby Math tan()用法及代碼示例
- Ruby CMath cosh()用法及代碼示例
- Ruby Math cbrt()用法及代碼示例
- Ruby Math atanh()用法及代碼示例
- Ruby Math erfc()用法及代碼示例
- Ruby Math sqrt()用法及代碼示例
- Ruby Math acosh()用法及代碼示例
- Ruby Math asin()用法及代碼示例
- Ruby Math asinh()用法及代碼示例
- Ruby Math acos()用法及代碼示例
注:本文由純淨天空篩選整理自gopaldave大神的英文原創作品 Ruby | Math cosh() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。