Solution (source code)

= Solution

Using $\cos z=(e^{iz}+e^{-iz})/2$ and collecting real and imaginary terms gives the <complex cosine> identity $\cos(x+iy)=\cos x\cosh y-i\sin x\sinh y$. Thus
$$
\boxed{\operatorname{Re}(\cos z)=\cos x\cosh y,\qquad \operatorname{Im}(\cos z)=-\sin x\sinh y.}
$$
The sign follows from the factors $e^{-y}$ and $e^y$ in the two <complex exponentials>.