📜  Ruby CMath cosh() 方法与示例

📅  最后修改于: 2022-05-13 01:55:06.577000             🧑  作者: Mango

Ruby CMath cosh() 方法与示例

cosh() 方法是 Math 类,用于返回给定值的双曲余弦值。

示例 1:

# Ruby code for cosh() method
require 'cmath'
  
# Initializing value  
a = 0.3584
b = 2
  
# Printing result   
puts "cosh value of a : #{CMath.cosh(a)}\n\n"  
puts "cosh value of b : #{CMath.cosh(b)}\n\n"

输出:

cosh value of a : 1.0649157114377563

cosh value of b : 3.7621956910836314

示例 2:

# Ruby code for cosh() method
require 'cmath'
  
# Initializing values  
a = 0
b = -0.247
  
# Printing result   
puts "cosh value of a : #{CMath.cosh(a)}\n\n"  
puts "cosh value of b : #{CMath.cosh(b)}\n\n"

输出:

cosh value of a : 1.0

cosh value of b : 1.0306599031548231