Solution (source code)

= Solution

A sufficient condition is that $U$ is a <connected space>. Suppose, towards a contradiction, that $|f|$ is the same constant $R$ throughout $U$. If $R=0$, then $f=0$, contradicting $f(a)\ne f(b)$.

If $R>0$, differentiate $u^2+v^2=R^2$ in $x$ and $y$, and use the <Cauchy-Riemann equations> from part (a). They give
$$
uu_x+vv_x=0,\qquad vu_x-uv_x=0.
$$
The coefficient <matrix> for $(u_x,v_x)$ has <determinant> $-(u^2+v^2)=-R^2\ne0$. Hence $u_x=v_x=0$, so $f'=0$ everywhere. A <holomorphic function> with zero <complex derivative> is locally constant: within a small disc, differentiate along a straight segment. Local constancy and <connectedness> imply constancy on $U$, again a contradiction.

Consequently,
$$
\boxed{U\text{ connected and }f(a)\ne f(b)\ \Longrightarrow\ \exists c,d\in U:\ |f(c)|\ne|f(d)|}.
$$
This is the <constant-modulus holomorphic function> principle. The extra hypothesis matters: on two disjoint <open discs>, define $f=1$ on one and $f=-1$ on the other. It is <holomorphic> and nonconstant, yet $|f|=1$ everywhere.