📜  红宝石 |数学 atan()函数

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

红宝石 |数学 atan()函数

atan()是 Ruby 中的一个内置函数,返回一个数字的反正切值,这意味着给这个函数一个正切值,它将返回对应于该值的弧度角。反正切是正切的逆运算。此函数接受 [-inf, +inf] 范围内的所有数字。

示例 1

#Ruby program for atan() function
  
#Assigning values
val1 = 1 val2 = 0.5 val3 = -1 val4 = -0.9
  
#Prints the atan() value
                                      puts Math.atan(val1)
                                          puts Math.atan(val2)
                                              puts Math.atan(val3)
                                                  puts Math.atan(val4)

输出

0.7853981633974483
0.4636476090008061
-0.7853981633974483
-0.7328151017865066

示例 2

#Ruby program for atan() function
  
#Assigning values
val1 = 0.9 val2 = 0.2 val3 = -0.78 val4 = -0.32
  
#Prints the atan() value
                                           puts Math.atan(val1)
                                               puts Math.atan(val2)
                                                   puts Math.atan(val3)
                                                       puts Math.atan(val4)

输出

0.7328151017865066
0.19739555984988078
-0.6624262938331512
-0.3097029445424562

参考:https://devdocs.io/ruby~2.5/math#method-c-atan