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

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

红宝石 |数学 asin()函数

asin()是 Ruby 中的一个内置函数,它返回一个数字的反正弦值,这意味着给这个函数一个 sin 值,它将返回对应于该值的弧度角。传递的值介于 -1 和 +1 之间。

示例 1

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


Ruby
#Ruby program for asin() function
 
#Assigning values
val1 = 0.87 val2 = 0.67 val3 = -0.679 val4 = -0.564
 
#Prints the asin() value
                                              puts Math.asin(val1)
                                                  puts Math.asin(val2)
                                                      puts Math.asin(val3)
                                                          puts Math.asin(val4)


输出

1.5707963267948966
0.5235987755982989
-1.5707963267948966
-1.1197695149986342

示例 2

红宝石

#Ruby program for asin() function
 
#Assigning values
val1 = 0.87 val2 = 0.67 val3 = -0.679 val4 = -0.564
 
#Prints the asin() value
                                              puts Math.asin(val1)
                                                  puts Math.asin(val2)
                                                      puts Math.asin(val3)
                                                          puts Math.asin(val4)

输出

1.0552023205488061
0.7342087874533589
-0.746399633896421
-0.59922176813665

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