Solution (source code)

= Solution

For the real part specified in the PDF,
$$
u_x=(\cos x-x\sin x)\cosh y+y\cos x\sinh y.
$$
Integrating $v_y=u_x$ gives
$$
v=y\cos x\cosh y-x\sin x\sinh y+h(x).
$$
Substitution into $v_x=-u_y$ shows $h'(x)=0$. Thus
$$
\boxed{f(z)=z\cos z+iC,\qquad C\in\mathbb R.}
$$
Indeed $\cos(x+iy)=\cos x\cosh y-i\sin x\sinh y$, so the real part of $z\cos z$ is exactly the prescribed expression. The arbitrary imaginary constant is the only freedom on a connected domain.