📜  Ruby CMath atan() 方法与示例

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

Ruby CMath atan() 方法与示例

atan() 方法是 CMath 类,用于返回给定值的反正切。

示例 1:

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

输出:

atan value of a : 0.34413842830780517

atan value of b : 1.1071487177940904

示例 2:

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

输出:

atan value of a : 0.0

atan value of b : -0.24215314674687552