If $f$ is a complex polynomial such that $f(z) \in \mathbb{R}$ whenever $|z| = 1$, then $f$ is constant.

I think we can do this from scratch, especially since we are given that $f$ is a polynomial:

Let $\mathbb T$ be the unit circle, and $f$ a polynomial of degree $n$.

For $z=e^{it}$, consider the real number

$f(e^{it})=a_0 +a_1e^{it}+a_2e^{2it}+\cdots a_{n}e^{nit}.$

The imaginary part of this must be equal to zero, so

$Im\ a_0+\sum^{n}_{k=1}(Re\ a_k\sin kt+Im\ a_k\cos kt)=0$.

But now, linear independence of the set $\left \{1, \sin kt,\cos kt \right \}^{n}_{k=1}$ on $\mathbb T$ implies that

$Im\ a_0=a_1=\cdots=a_n=0$ so $f(z)=Re\ a_0$.


Let $B$ be the open unit ball centered at the origin. Then its closure $\bar{B}$ is the closed unit ball centered at the origin, and its boundary $\partial B$ is the unit circle $S^1$. We are given that $f(\partial B) \subset \Bbb{R}$. Suppose for the sake of contradiction that $f$ is a nonconstant polynomial function.

We show that $\partial(f(B)) \subset f(\partial B)$. Since $\bar{B}$ is compact, and the continuous image of a compact set is compact, $f(\bar{B})$ is compact. By the Heine-Borel theorem, $f(\bar{B})$ is closed and bounded. Hence, $$ B \subset \bar{B} \implies f(B) \subset f(\bar{B}) \implies \overline{f(B)} \subset \overline{f(\bar{B})} = f(\bar{B}). $$ Therefore, $$ \overline{f(B)} \subset f(\bar{B}).\tag{$*$} $$ Now, by definition we have $\partial(f(B)) = \overline{f(B)} \setminus f(B)^o$, where $f(B)^o$ is the interior of $f(B)$. Since polynomial functions are holomorphic, by the open mapping theorem $f(B)$ is open, so $f(B)^o = f(B)$. Using this and $(*)$, we get $$ \partial(f(B)) = \overline{f(B)} \setminus f(B)^o \subset f(\bar{B}) \setminus f(B) \subset f(\bar{B} \setminus B) = f(\partial B). $$

Hence, $$ \partial(f(B)) \subset f(\partial B) \subset \Bbb{R}.\tag{$\dagger$} $$

Now, since $f(B) \subset f(\bar{B})$ which is bounded, $f(B)$ is a bounded open subset of $\Bbb{C}$. Therefore, $f(B)$ must have boundary points lying outside $\Bbb{R}$ as well, which contradicts $(\dagger)$. To see why this is true, choose any $z \in f(B)$ and suppose wlog that $\mathrm{Im}(z) \geq 0$. Consider the vertical ray in the upper half plane starting at $z$, given by $\{ z + it : t \geq 0 \}$. Since $f(B)$ is bounded, there exists $t \geq 0$ such that $z+it \not\in f(B)$. Let $s = \inf \{t \geq 0 : z+it \not\in f(B)\}$. Then, $s$ exists and $s > 0$, and the point $z+is$ is a boundary point of $f(B)$ that does not lie on the real axis. (If $\mathrm{Im}(z) \leq 0$, then we consider the vertical ray in the lower half plane starting at $z$ and arrive at a contradiction in a similar manner.)

Thus, we have a contradiction, and hence $f$ must be constant.


If we set $$ u(x,y)=\mathrm{Im}\,f(x+iy), $$ then $u$ is a harmonic function, which vanishes on the unit circle. Maximum (together with Minimum) Principle for harmonic function imply that $$ \max_{x^2+y^2\le 1}{u(x,y)}=\max_{x^2+y^2=1}{u(x,y)}=0 \quad\text{and}\quad \min_{x^2+y^2\le 1}{u(x,y)}=\min_{x^2+y^2=1}{u(x,y)}=0 $$ Hence, $u\equiv 0$ in the closed unit disk, and hence $u\equiv 0$ everywhere. (Identity Principle.)

Thus $f$ takes only real values, and hence $f$ is constant.