Ruby | Math tan() function

The tan() is an inbuilt function in Ruby returns the tangent of a given angle expressed in radians which is in range [-inf, +inf]. The returned value is in range [-inf, +inf].

Syntax: Math.tan(value)

Parameters: The function accepts one mandatory parameter value whose corresponding tangent value is returned.



Return Value: It returns the tangent value.

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

#Ruby program for tan() function
  
#Assigning values
val1 = 1 val2 = 0 val3 = 989 val4 = -8932
  
#Prints the tan() value
                                     puts Math.tan(val1)
                                         puts Math.tan(val2)
                                             puts Math.tan(val3)
                                                 puts Math.tan(val4)

chevron_right


Output:

1.5574077246549023
0.0
-0.6866146142998235
-0.48563022371184766

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

#Ruby program for tan() function
  
#Assigning values
val1 = -1023 val2 = 0.67 val3 = 98 val4 = -39
  
#Prints the tan() value
                                           puts Math.tan(val1)
                                               puts Math.tan(val2)
                                                   puts Math.tan(val3)
                                                       puts Math.tan(val4)

chevron_right


Output:

2.290822861412639
0.7922541747282569
0.6998536538095259
-3.614554407101535

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



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.