Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Ruby CMath atan() Method with example

  • Last Updated : 07 Jan, 2020

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:






# Ruby code for atan() method
require 'cmath'
  
# Initializing value  
a = 0.3584
b = 2
  
# Printing result   
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:




# Ruby code for atan() method
require 'cmath'
  
# Initializing value  
a = 0
b = -0.247
  
# Printing result   
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
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!