Let $G$ be a connected set and $f : G \rightarrow \mathbb{C}$ a real valued analytic function. Prove that $f$ is constant.
My idea to prove the result is to prove a subset $A \neq \varnothing$ of the connected set $G$ is both open and closed. So $G=A$ Take $f(w) = a$ $$A = \{z\colon z \in G, f(z) = a\}$$ Now I want to show that $A$ is infinite. How to do it? After that it is easy to prove $A=G$.
$\endgroup$ 61 Answer
$\begingroup$This isn 't an answer to your question, but rather an answer to your problem.
Let $f$ be an holomorphic function on a connected set $G$.
There exist functions $u,v$ such that $f=u+iv$.
Now using Daniel Fischer's hint, since $f$ is holomorphic, $u_x=v_y$ and $u_y=-v_x$. By hypothesis $\text{im}(f)\subseteq \Bbb R$, therefore $v=\textbf 0$ and it follows that $u_x=\textbf 0= v_x$.
Finally use the $f'=u_x+iv_x$ and the fact that $G$ is connected to conclude. (This is used in the last step).
$\endgroup$ 1