Let $f$ be a holomorphic function defined on $\Bbb C$ such that $f^{-1}(\Bbb R)=\Bbb R$. Prove that there exists $a,b \in \Bbb R, \; a \neq 0 \;$ such that $f(z)=az+b \;$ for every $z \in \Bbb C$.
I was given a hint: define the function $g(z)=\frac{f(z)-f(0)}{z}$. such $g$ is also holomorphic in $\Bbb C$ since the only singularity is in $0$, and it is a removable singularity since we can define $g(0)=f'(0)$. Next I thought about proving $g$ is bounded, and thus constant (using Liouville's theorem), but pretty much out of ideas. How can I finish the proof/solve in another way?
The answer provided in this link uses the big Picard theorem. But that is a big weapon to use here. Here's a proof based on a more elementary result. Below $H_+,H_-$ denote the open upper and lower half planes.
I'll sketch a proof of the theorem below. For now, on to our problem: The hypotheses imply $f(H_+)\subset H_+\cup H_-.$ Since $H_+,H_-$ are disjoint nonempty open sets, we have by continuity and connectedness that one of the following holds: i) $f(H_+)\subset f(H_+)$ ii) $f(H_+)\subset H_-.$ Suppose WLOG i) holds.
Writing $f=u+iv,$ we then see that $v,$ restricted to $\overline {H_+},$ satisfies the hypotheses of the theorem. Note also that since $f:\mathbb R\to \mathbb R,$ we have $f(\bar z) = \overline {f(z)}.$ This implies $v(x,-y) = -v(x,y).$ The theorem thus implies there is $a>0$ such that $v(x,y) = ay$ everywhere.
From this it follows easily that $u(x,y) = ax +b$ for some real constant $b.$ Thus $f(x+iy) = a(x+iy) + b$ as desired.
Proof of Thm: The analogue for the unit disc is better known. There we would have $v$ continuous on $\overline {\mathbb D}\setminus \{1\},$ $v$ positive and harmonic on $\mathbb D,$ and $v=0$ on the boundary minus the point $1.$ In this situation, $v$ must be a positive constant multiple of $(1-|z|^2)/|1-z|^2,$ which you will recognize as the Poisson kernel for the disc, based at $1.$ This result falls right out of the representation of positive harmonic functions in the disc as Poisson integrals of finite positive measures on the boundary. For us the important thing is that all of these functions are positive constant multiples of each other. Via a conformal map of $\mathbb D$ onto $H_+$ that takes $1$ to $\infty,$ we see the same is true for the functions in the theorem. Since we know one such function, namely $(x,y)\to y,$ we have the desired conclusion.