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

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

红宝石 |数学 acos()函数

acos()是 Ruby 中的一个内置函数,它以弧度返回数字(参数)的反余弦值。 acos()函数返回的值总是介于–pi+pi之间。

示例 1

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

输出

0.0
3.141592653589793
1.0471975511965979
2.3461938234056494

示例 2

#Ruby program for acos() function
  
#Assigning values
val1 = 0.8 val2 = -0.955 val3 = 0.74 val4 = -0.356
  
#Prints the acos() value
                                             puts Math.acos(val1)
                                                 puts Math.acos(val2)
                                                     puts Math.acos(val3)
                                                         puts Math.acos(val4)

输出

0.6435011087932843
2.8404561080364212
0.7377259684532488
1.9347802832764904