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