VOOZH about

URL: https://www.geeksforgeeks.org/ruby/ruby-math-atan-function/

⇱ Ruby | Math atan() function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Ruby | Math atan() function

Last Updated : 12 Jul, 2025
The atan() is an inbuilt function in Ruby returns the arc tangent of a number means give a tangent value to this function it will return the angle in radian corresponding to that value. arc tangent is the inverse operation of tangent. This function accepts all numbers in range [-inf, +inf].
Syntax: Math.atan(value) Parameters: The function accepts one mandatory parameter value whose corresponding angle we have to find. Return Value: It returns the angle in radians which in range -pi/2 to +pi/2.
Example 1: Output:
0.7853981633974483
0.4636476090008061
-0.7853981633974483
-0.7328151017865066
Example 2: Output:
0.7328151017865066
0.19739555984988078
-0.6624262938331512
-0.3097029445424562
Reference: https://devdocs.io/ruby~2.5/math#method-c-atan
Comment