What happens if $|f|$ is constant in the boundary of the image

Let D be a domain and let $f$ be analytic on $D$ and continuous on $\overline{D}$. Suppose $|f|$ is constant on $\overline{D}-D$. So from this can we say that $f$ is constant in $D$? I suppose $f$ is constant but then again I do not know how to prove this. Any help will be appreciated. Thanks

EDIT: D here is a bounded domain and f is not 0 anywhere in the domain

• Counterexample: $f(z) = z$, $D = \{z: |z| < 1\}$ – Petite Etincelle Nov 11 '14 at 13:34
• Petite's example isn't the only one either, any monomial and any disk centered at the origin will do the job. $\exp$ on the left or right half plane is a somewhat more exotic example. – Ian Nov 11 '14 at 13:35
• @PetiteEtincelle I see that my question has a small flaw. What if cannot be 0 anywhere? – Heisenberg Nov 11 '14 at 13:38
• @Heisenberg In that case my example with $\exp$ comes into play. (My example doesn't work on any bounded domain, however.) – Ian Nov 11 '14 at 13:38
• @Ian How does exp work? – Heisenberg Nov 11 '14 at 13:51

If $D$ is a bounded domain and $f$ is not zero anywhere in the domain, then $|f|$ is constant on $\bar{D} - D$ implies $f$ is a constant:
Suppose $f$ is not a constant and $|f(z)| = C$ on $\bar{D} - D$, by maximal modulus principle, we know that for all $z \in D$, $|f(z)| < C$. Because $|f(z)|$ is a continuous function on the bounded $\bar{D}$, then it reached its maximal value on some point in $\bar{D}$. If the maximal value is reached inside $D$, then it's against maximal modulus principle since $f$ is not a constant.
Similarly, we have $\frac{1}{f}$ is not a constant and $\left|\dfrac{1}{f(z)}\right| = \dfrac{1}{C}$ on $\bar{D} - D$, by maximal modulus principle, we know that for all $z \in D$, $\left|\dfrac{1}{f(z)}\right| < \dfrac{1}{C}$.
Then we get a contradiction since we can't have $|f(z)| < C$ and $\left|\dfrac{1}{f(z)}\right| < \dfrac{1}{C}$ at the same time
• If $f$ vanishes somewhere, then my first comment under the question shows $f$ needs not to be a constant – Petite Etincelle Nov 11 '14 at 14:44