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:

filter_none

edit
close

play_arrow

link
brightness_4
code

#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)

chevron_right


Output:

 0.07075223608034517
1.0
-0.25408576770942626
-0.8600694058124533

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

#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)

chevron_right


Output:

0.8414709848078965
0.0
0.5660330877786267
0.43684277891924755

Reference: https://devdocs.io/ruby~2.5/math#method-c-sin



My Personal Notes arrow_drop_up

The function of education is to teach one to think intensively and to think critically

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.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.