Open In App

Ruby | Math tan() function

Last Updated : 07 Jan, 2020
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report
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: CPP
#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)
Output:
1.5574077246549023
0.0
-0.6866146142998235
-0.48563022371184766
Example 2: CPP
#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)
Output:
2.290822861412639
0.7922541747282569
0.6998536538095259
-3.614554407101535
Reference: https://devdocs.io/ruby~2.5/math#method-c-tan

Next Article

Similar Reads