红宝石 |数学 asin()函数
asin()是 Ruby 中的一个内置函数,它返回一个数字的反正弦值,这意味着给这个函数一个 sin 值,它将返回对应于该值的弧度角。传递的值介于 -1 和 +1 之间。
Syntax: Math.asin(value)
Parameters: The function accepts one mandatory parameter value whose corresponding angle we have to find.
Return Value: It returns the angle in radians which in range -pi/2 to +pi/2.
示例 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