The sin() is an inbuilt function in Ruby returns the sine of a given angle expressed in radians which is in range [-inf, +inf]. The returned value is in range [-1, +1].
Syntax: Math.sin(value)
Parameters: The function accepts one mandatory parameter value whose corresponding sine is returned.
Return Value: It returns the sine.
Example 1:
Ruby
#Ruby program for sin() function #Assigning values val1 = 176 val2 = Math:: PI / 2 val3 = - 3123 val4 = - 89
#Prints the sin() value puts Math.sin(val1)
puts Math.sin(val2)
puts Math.sin(val3)
puts Math.sin(val4)
|
Output:
0.07075223608034517 1.0 -0.25408576770942626 -0.8600694058124533
Example 2:
Ruby
#Ruby program for sin() function #Assigning values val1 = 1 val2 = 0 val3 = 989 val4 = - 8932
#Prints the sin() value puts Math.sin(val1)
puts Math.sin(val2)
puts Math.sin(val3)
puts Math.sin(val4)
|
Output:
0.8414709848078965 0.0 0.5660330877786267 0.43684277891924755
Reference: https://devdocs.io/ruby~2.5/math#method-c-sin