⊕
⊖
Contents
Python math.acos()
math.acos() function returns the inverse cosine of given number.
The return value is angle in radians, and lies in [0, pi] radians.
Syntax
The syntax to call acos() function is
math.acos(x)
where
Parameter | Required | Description |
---|---|---|
x | Yes | A number in the range [-1, 1]. |
Note: If x is outside the allowed range, then acos(x) raises a ValueError.
Examples
In the following example, we find the inverse cosine of 0.5 using acos() function of math module.
Python Program
import math
x = 0.5
result = math.acos(x)
print('acos(x) :', result, 'radians')
Run Code CopyOutput
acos(x) : 1.0471975511965976 radians
We can convert the returned radians into degrees using math.degrees() function.
In the following example, we find the inverse cosine of 0.5 using acos() function and convert this returned radians to degrees.
Python Program
import math
x = 0.5
result = math.acos(x)
result = math.degrees(result)
print('acos(x) :', result, 'degrees')
Run Code CopyOutput
acos(x) : 59.99999999999999 degrees
Summary
In this Python Examples tutorial, we learned the syntax of, and examples for math.acos() function.