Inverse Cosine in Python

Sheik Yerbouti picture Sheik Yerbouti · Jul 19, 2011 · Viewed 92.5k times · Source

Apologies if this is straight forward, but I have not found any help in the python manual or google.

I am trying to find the inverse cosine for a value using python.

i.e. cos⁻¹(x)

Does anyone know how to do this?

Thanks

Answer

Tugrul Ates picture Tugrul Ates · Jul 19, 2011

We have the acos function, which returns the angle in radians.

>>> import math
>>> math.acos(0)
1.5707963267948966
>>> _ * 2 - math.pi
0.0