Solution (source code)

= Solution

To invert the complex <cosine>, let $z=\cos w$ and put $u=e^{iw}$. Since the <exponential function> is nonzero, $u\ne0$, and <Euler's formula> gives $2z=u+u^{-1}$. Multiplying by $u$ yields the <quadratic equation> $u^2-2zu+1=0$. Thus
$$
u=z\pm\sqrt{z^2-1}=z\pm i\sqrt{1-z^2}.
$$
Choosing either <square root> of $1-z^2$ merely exchanges the two signs. The two values have product one, so neither vanishes; taking a <complex logarithm> is legitimate.

For each choice of sign, all solutions of $e^{iw}=u$ satisfy $iw=\operatorname{Log}u+2\pi in$. Therefore the full inverse relation is
$$
\boxed{w=-i\operatorname{Log}\left(z\pm i\sqrt{1-z^2}\right)+2\pi n,\qquad n\in\mathbb Z.}
$$
Conversely, exponentiating any displayed value recovers one root of the <quadratic equation>, and hence $(e^{iw}+e^{-iw})/2=z$, proving completeness. With a multivalued <complex logarithm>, the $2\pi n$ term is already included and this is the source's compact formula for <inverse cosine>.

The principal <inverse cosine> requires compatible choices of <logarithm branch>, <square root> and sign. Both signs cannot represent that same principal function indiscriminately: at $z=0$, the two principal-log values are $\pi/2$ and $-\pi/2$, whereas the principal $\arccos0$ is $\pi/2$. Thus the printed $\pm$ is correct for the inverse relation, not a pair of interchangeable principal-value formulas.