# Ruby | Math acos() function

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:

 `#Ruby program for acos() function ` ` `  `#Assigning values ` `val1 = 1 val2 = -1 val3 = 0.5 val4 = -0.7 ` ` `  `#Prints the acos() value ` `                                      ``puts` `Math.``acos``(val1) ` `                                          ``puts` `Math.``acos``(val2) ` `                                              ``puts` `Math.``acos``(val3) ` `                                                  ``puts` `Math.``acos``(val4) `

Output:

```0.0
3.141592653589793
1.0471975511965979
2.3461938234056494
```

Example 2:

 `#Ruby program for acos() function ` ` `  `#Assigning values ` `val1 = 0.8 val2 = -0.955 val3 = 0.74 val4 = -0.356 ` ` `  `#Prints the acos() value ` `                                             ``puts` `Math.``acos``(val1) ` `                                                 ``puts` `Math.``acos``(val2) ` `                                                     ``puts` `Math.``acos``(val3) ` `                                                         ``puts` `Math.``acos``(val4) `

Output:

```0.6435011087932843
2.8404561080364212
0.7377259684532488
1.9347802832764904
```

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.