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:
#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:
#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
Recommended Posts:
- Ruby | Math cos() function
- Ruby | Math sin() function
- Ruby | Math erf() function
- Ruby | Math exp() function
- Ruby | Math log() function
- Ruby | Math sinh() function
- Ruby | Math tanh() function
- Ruby | Math sqrt() function
- Ruby | Math cosh() function
- Ruby | Math atanh() function
- Ruby | Math cbrt() function
- Ruby | Math atan2() function
- Ruby | Math atan() function
- Ruby | Math acos() function
- Ruby | Math lgamma() 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.



