Ruby CMath tan() Method with example
Last Updated :
07 Jan, 2020
tan() method is Math class which is used to returns the tangent of the given value.
Syntax: Math.tan(z)
Parameter: Here, z is the value whose tangent is to be calculated.
Returns: This method returns the tangent value of the z.
Example 1:
require 'cmath'
a = 0 . 3584
b = 2
puts "tan value of a : #{CMath.tan(a)}\n\n"
puts "tan value of b : #{CMath.tan(b)}\n\n"
|
Output:
tan value of a : 0.374577262964287
tan value of b : -2.185039863261519
Example 2:
require 'cmath'
a = 0
b = - 0 . 247
puts "tan value of a : #{CMath.tan(a)}\n\n"
puts "tan value of b : #{CMath.tan(b)}\n\n"
|
Output:
tan value of a : 0.0
tan value of b : -0.2521487591957248
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...