Ruby | Math asin() function
The asin() is an inbuilt function in Ruby returns the arc sine of a number means give a sin value to this function it will return the angle in radian corresponding to that value. The value passed is in between -1 and +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.
Example 1:
Ruby
val1 = 1 val2 = 0 . 5 val3 = - 1 val4 = - 0 . 9
puts Math.asin(val1)
puts Math.asin(val2)
puts Math.asin(val3)
puts Math.asin(val4)
|
Output:
1.5707963267948966
0.5235987755982989
-1.5707963267948966
-1.1197695149986342
Example 2:
Ruby
val1 = 0 . 87 val2 = 0 . 67 val3 = - 0 . 679 val4 = - 0 . 564
puts Math.asin(val1)
puts Math.asin(val2)
puts Math.asin(val3)
puts Math.asin(val4)
|
Output:
1.0552023205488061
0.7342087874533589
-0.746399633896421
-0.59922176813665
Reference: https://devdocs.io/ruby~2.5/math#method-c-asin
Last Updated :
04 Dec, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...