VOOZH about

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

⇱ Ruby | Math acos() function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Ruby | Math acos() function

Last Updated : 12 Jul, 2025
The acos() is an inbuilt function in Ruby which returns the inverse cosine of a number (argument) in radians. The value which is returned by the acos() function always lies between –pi to +pi.
Syntax: Math.acos(value) Parameters: This function accepts one mandatory parameter value which specifies the value whose inverse cosine should be computed. It must lie between -1 and +1, else a domain-error is thrown. Return Value: The function returns a numeric value between –pi and +pi. It is the counterclockwise angle which is measured in radian.
Example 1: Output:
0.0
3.141592653589793
1.0471975511965979
2.3461938234056494
Example 2: Output:
0.6435011087932843
2.8404561080364212
0.7377259684532488
1.9347802832764904
Comment