Why is the following proof about an analytic function attaining the maximum on the boundary true

analysiscomplex-analysismaximum-principle

I have the following statement

Let $D\subset \Bbb{C}$ be a bounded open nonempty subset. Take $\bar D$ to be the closure of $D$. Let $$f:\bar D\rightarrow \Bbb{C}$$be a continuous function which is analytic on $D\subset \bar D$. Then $|f(z)|$ attains the maximum at some point on the boundary of $D$.

I have given the following proof:

Since $\bar D$ is compact and $|f|$ is continuous we know that $|f|$ attains the maximum $z_0\in \bar D$. Assume $z_0$ is not on the boundary. Then by the maximum principle $f$ is constant. Hence $|f|$ attains the maximum everywhere so also on the boundary which is a contradiction. Thus $z_0$ needs to be on the boundary.

Now I don't see why this prove is correct. I mean in my opinion the maximum principle only tells me that $f$ is constant in $D$. But we have no information about the boundary of $D$? How is it then possible to conclude that the maximum is on the boundary which gives us a contradiction?

Can maybe someone help me?

Thanks

Best Answer

If $f$ is constant on $D$ and continuous on $\bar D$, then it is constant on $\bar D$. Indeeed, if $z\in \bar D$, then there exists a sequence $(z_n)$ in $D$ such that $z_n\to z$. Since $f$ is continuous on $\bar D$, this implies $f(z)=\lim_{n\to\infty}f(z_n)=f(z_1)$, where $f(z_1)$ is the constant value of $f$ on $D$. Thus $f$ takes the same value at $z$ as everywhere on $D$.