>>> from sympy import *
>>> x,y=map(symbols, "xy")
Abraham de Moivre taught us that :
>>> cos(x).rewrite(exp)
exp(I*x)/2 + exp(-I*x)/2
This expression can be solved for all possible values, not only for reals of absolute value not superior to 1. However, the latter are the only ones for which the solution is real. Generally :
>>> solve(Eq(y,cos(x).rewrite(exp)), x)
[-I*log(y - sqrt(y**2 - 1)), -I*log(y + sqrt(y**2 - 1))]
Sympy’sacos returns one of these values.
HTH,