Ruby | Math sin() function
The cos() 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.cos(value)
Parameters: The function accepts one mandatory parameter value whose corresponding sine is returned.
Return Value: It returns the sine.
Example 1:
#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 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
Recommended Posts:
- Ruby | Math cos() function
- Ruby | Math erf() function
- Ruby | Math log() function
- Ruby | Math tan() function
- Ruby | Math exp() function
- Ruby | Math atan2() function
- Ruby | Math atanh() function
- Ruby | Math log2() function
- Ruby | Math sqrt() function
- Ruby | Math cbrt() function
- Ruby | Math atan() function
- Ruby | Math erfc() function
- Ruby | Math cosh() function
- Ruby | Math frexp() function
- Ruby | Math hypot() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.